View Full Version : Urgent Javascript help needed - Breadcrumb Script
txwebdesign
Nov 26th 2006, 12:33 pm
First, I used this script:
http://www.javascriptkit.com/script/script2/breadcrumb.shtml
The script works fine but all of my pages are showing up in just one
"directory" (Home.) For instance, Home > How to Order, Home > Custom Drapes, etc... The script supposedly shows the links based on the "Directory Tree" but I'm not sure how to edit my web pages in the Directory Tree. I tried just creating the navigation by dragging & dropping the pages into the navigation tree but that didn't work.
Does anyone know how to create the directories or make certain pages "under" other pages?
Thanks!
Beverly
the_pm
Dec 4th 2006, 6:51 am
It appears you create your structure by placing your pages within folders. The script uses those folder names to populate your breadcrumbs.
So, "Home > How to Order" would be achieved by having a How To Order page in your root web directory. If you wanted "Home > How to Order > Order By Credit Card" you would need to have Order By Credit Card inside a How To Order folder.
txwebdesign
Dec 7th 2006, 9:53 am
Need further help, please...
When I create a folder (ie "Sample Folder"), when it shows up in my browser, it shows as "Sample%20Folder" - How do I get rid of the "%20" that shows up where I have a space in the folder name? Thanks!!
the_pm
Dec 7th 2006, 10:17 am
Try adding:
url = url.replace(/%20/g,' ');
right before the writeln statement. That should replace all instances of %20 with a space.
txwebdesign
Dec 7th 2006, 10:27 am
Can you confirm where "right before the writeln statement" is? Do you mean before this line?
document.write(output + document.title);
Thanks!
the_pm
Dec 7th 2006, 10:33 am
Umm, I'm not seeing the line of code you referenced.
Here - I pulled the script off the link you provided in your first post, and I inserted a little comment to tell you where to put that one line of code I wrote:<SCRIPT LANGUAGE="JavaScript">
<!--
//Bread crumb script - Kevin Lynn Brown
//Duplicate directory names bug fix by JavaScriptKit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
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+1)+"/\">"+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;
// \/ \/ \/ \/ \/ PUT YOUR CODE IN HERE \/ \/ \/ \/ \/
// /\ /\ /\ /\ /\ PUT YOUR CODE IN HERE /\ /\ /\ /\ /\
document.writeln(url);
//-->
</script>
<p align="left"><font face="arial" size="-2">This free script provided by <a target=_top href="http://javascriptkit.com">JavaScript Kit</a></font></p>
Can't miss it :)
If this isn't the script you're using, post the actual script, and I'll edit that one for you.
txwebdesign
Dec 7th 2006, 2:01 pm
Thanks so much for your help... It is a different script (sorry) but I think I must have put it in the wrong spot b/c nothing changed....
http://www.andrewcalzada.com/Custom%20Silk%20Drapes/test.htm
Please advise. Thanks again!
txwebdesign
Dec 7th 2006, 2:02 pm
Script looks like this:
function breadcrumbs(){
sURL = new String;
bits = new Object;
var x = 0;
var stop = 0;
var output = "<a href=\"/\">Home</a> » ";
sURL = location.href;
sURL = sURL.slice(8,sURL.length);
chunkStart = sURL.indexOf("/");
sURL = sURL.slice(chunkStart+1,sURL.length)
while(!stop){
chunkStart = sURL.indexOf("/");
if (chunkStart != -1){
bits[x] = sURL.slice(0,chunkStart)
sURL = sURL.slice(chunkStart+1,sURL.length);
}else{
stop = 1;
}
x++;
}
for(var i in bits){
output += "<a href=\"";
for(y=1;y<x-i;y++){
output += "../";
}
output += bits[i] + "/\">" + bits[i] + " » ";
}
document.write(output + document.title);
url = url.replace(/%20/g,' ');}
// -->
</script>
the_pm
Dec 7th 2006, 2:05 pm
Well yes, it won't work because the script variable is different here than in the first script you linked :)
Try this:
Function breadcrumbs(){
sURL = new String;
bits = new Object;
var x = 0;
var stop = 0;
var output = "<a href=\"/\">Home</a> » ";
sURL = location.href;
sURL = sURL.slice(8,sURL.length);
chunkStart = sURL.indexOf("/");
sURL = sURL.slice(chunkStart+1,sURL.length)
while(!stop){
chunkStart = sURL.indexOf("/");
if (chunkStart != -1){
bits[x] = sURL.slice(0,chunkStart)
sURL = sURL.slice(chunkStart+1,sURL.length);
}else{
stop = 1;
}
x++;
}
for(var i in bits){
output += "<a href=\"";
for(y=1;y<x-i;y++){
output += "../";
}
output += bits[i] + "/\">" + bits[i] + " » ";
ourput = output.replace(/%20/g,' ');
}
document.write(output + document.title);
}
txwebdesign
Dec 7th 2006, 9:25 pm
is that 4th line from the bottom supposed to be "output"? I assumed it was and inserted it. Now, the page has an error and won't load that breadcrumb.
http://www.andrewcalzada.com/Custom%20Silk%20Drapes/test.htm
Did I insert it correctly? Any other ideas? Thanks!
the_pm
Dec 8th 2006, 4:28 am
Try reverting it back to the original. I'm using the markup you provided above to test this, and it's not working. If I can pull the working markup out of your site, I'll be able to modify it properly. Thanks!
txwebdesign
Dec 11th 2006, 1:30 pm
Ok, I reverted back to the original script. Here's the test link:
http://www.andrewcalzada.com/Custom%20Silk%20Drapes/test.htm
Thanks!!
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.