jibip
asked on
Change "%20" in JavaScript to a html-friendly "space" character in a breadcrumbs script
I am using a script to create breadcrumbs on my website. The code is posted below. If one of the folders on the website has spaces, it displays the breadcrumb with the %20 instead an "html" space character, usually "nbsp;"
Can someone show me how to edit my script to do this? By the way, I don't have great javascript skills. This is a slightly modified script I found on the web. Thanks.
CODE:
function breadcrumbs(){
sURL = new String;
bits = new Object;
var x = 0;
var stop = 0;
var output = "<a href=\"/\" class=\"headlinkText\">Hom e</a> > ";
sURL = location.href;
sURL = sURL.slice(8,sURL.length);
chunkStart = sURL.indexOf("/");
sURL = sURL.slice(chunkStart+1,sU RL.length)
while(!stop){
chunkStart = sURL.indexOf("/");
if (chunkStart != -1){
bits[x] = sURL.slice(0,chunkStart)
sURL = sURL.slice(chunkStart+1,sU RL.length) ;
}else{
stop = 1;
}
x++;
}
for(var i in bits){
output += "<a class=\"headlinkText\" href=\"";
for(y=1;y<x-i;y++){
output += "../";
}
output += bits[i] + "/\">" + bits[i] + "</a> > ";
}
document.write(output + "<span class=\"style2\">" + document.title + "</span>");
}
Can someone show me how to edit my script to do this? By the way, I don't have great javascript skills. This is a slightly modified script I found on the web. Thanks.
CODE:
function breadcrumbs(){
sURL = new String;
bits = new Object;
var x = 0;
var stop = 0;
var output = "<a href=\"/\" class=\"headlinkText\">Hom
sURL = location.href;
sURL = sURL.slice(8,sURL.length);
chunkStart = sURL.indexOf("/");
sURL = sURL.slice(chunkStart+1,sU
while(!stop){
chunkStart = sURL.indexOf("/");
if (chunkStart != -1){
bits[x] = sURL.slice(0,chunkStart)
sURL = sURL.slice(chunkStart+1,sU
}else{
stop = 1;
}
x++;
}
for(var i in bits){
output += "<a class=\"headlinkText\" href=\"";
for(y=1;y<x-i;y++){
output += "../";
}
output += bits[i] + "/\">" + bits[i] + "</a> > ";
}
document.write(output + "<span class=\"style2\">" + document.title + "</span>");
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm glad that worked for you. Thanks for the grade, the points and the fun question.
bol
bol
ASKER