Link to home
Start Free TrialLog in
Avatar of jibip
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\">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 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
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jibip
jibip

ASKER

easy answer, as I suspected.  Thanks!
I'm glad that worked for you.  Thanks for the grade, the points and the fun question.

bol