Click to See Complete Forum and Search --> : Script/code required/wanted
car54
11-02-2003, 11:19 AM
Any one have this code???
Hi,
This may be a stupid question, but if I don't ask I won't get an answer.
I'm chasing the code that will give me something similar to what I have pointed out in the accompanying file "code.gif"
Download.com, Macromedia and a number of other sites I frequent have this feature "navigation aid"
Thanks.
Exuro
12-01-2003, 11:13 AM
I believe those are usually done with a server-side language like PHP or ASP, not JavaScript. But, if you really wanted to I suppose you could make one by disecting the parent.location string... I don't know how you would get the names of each "level" in your navigation tree from the URL though, unless you had each sub directory named exactly what you would want displayed on the screen... Maybe a case statement or an array? Anyway, hope this helps!
AdamGundry
12-01-2003, 11:49 AM
Those are called "breadcrumb trails", and should really be done using a server-side language, as Exuro said.
The following is a client-side script which may be something like you need, generating the tree based on subdirectories, but make sure your page is navigable without JS.
<script type="text/javascript">
var a = unescape(location.pathname.replace(/\\/g, '/')).split('/');
var b ='';
for (var i=0;i<a.length;i++){
b += a[i] + '/';
document.write('<a href="' + location.host + b + '">' + a[i] + '</a> / ');
}
</script>
Adam