tonygot
11-08-2012, 02:43 PM
Hi everyone. First post here. I want first thank the search feature for getting me to this point in my website design. I have been doing this for about 3 weeks so sorry for my lack of proper terminology.
My site is setup similar to CodingForums, using (index.php?page=about) for example, so each page is always loaded in the content area of the site. I have been trying to setup a breadcrumbs feature below my navbar using JS and obviously the crumbs will only read (Home) ,(Home » index) and will not output further into the site, it just stays at home>index. I understand it is a JS scripting issue but I am not knowledgeable enough to read and change JS script without messing it up. I would like the breadcrumbs to read from the title each page using the directory structure or hierarchy I suppose instead of the history "where I have been" method.
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 += bits[i] + "/\">" + bits[i] + " » ";
}
document.write(output + sURL.substring(0,((sURL.indexOf("."))?sURL.indexOf("."):sURL.length))
);;
}
Thanks in advance.:thumbsup::thumbsup:
My site is setup similar to CodingForums, using (index.php?page=about) for example, so each page is always loaded in the content area of the site. I have been trying to setup a breadcrumbs feature below my navbar using JS and obviously the crumbs will only read (Home) ,(Home » index) and will not output further into the site, it just stays at home>index. I understand it is a JS scripting issue but I am not knowledgeable enough to read and change JS script without messing it up. I would like the breadcrumbs to read from the title each page using the directory structure or hierarchy I suppose instead of the history "where I have been" method.
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 += bits[i] + "/\">" + bits[i] + " » ";
}
document.write(output + sURL.substring(0,((sURL.indexOf("."))?sURL.indexOf("."):sURL.length))
);;
}
Thanks in advance.:thumbsup::thumbsup: