PDA

View Full Version : Dynamic text links & Dir info


wjordaan
09-10-2002, 04:06 PM
Hi All.

I started using this code to display dynamic text links displaying the visitor's current location as text links (thanx to Kevin Lynn Brown).

The idea is that the user can jump back to any of the locations higher up the path.

This is the code:



<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var path = "";
var href = document.location.href;
var s = href.split("/");
for (var i=2;i<(s.length-1);i++) {
path+="<A HREF=\""+href.substring(0,href.indexOf(s[i])+s[i].length)+"/\">"+s[i]+"</A> > ";
}
i=s.length-1;
path+="<A HREF=\""+href.substring(0,href.indexOf(s[i])+s[i].length)+"\">"+s[i]+"</A>";
var url = window.location.protocol + "//" + path;
document.writeln(url);
// End -->

</script>



It would output something like:

http://tripletech006 > Projects > Barclays > Demo > Crestron > Laptop > index.htm

What I would like to achieve is to start displaying from 'Crestron and ignore everything else before that so, output should look like:

Crestron > Laptop > index.htm

The 'challange' is that the code will not always sit on the same machine, so we cannot just tell it to ignore a specific path.

Would it be a good idea to look for the first instance of a 'specified' word and then to use that as the start of the links to be displayed?

I have no idea where or how to do this, so any help would be appreciated.

Thanx.

Will.

Spookster
09-10-2002, 06:41 PM
The first thing you need to do is to put the credits for that script back into the script. It's fine that you referred to the author in your post however others that wander in here will copy the script as you have it and then the credits are lost. Here is the original script:

http://www.javascriptkit.com/script/script2/breadcrumb.shtml

Breadcrumb navigation becomes much easier when using a server-side language. If you are allowed to use one I would suggest going with that.