This is a function that creates breadcrumbs. It initially came from someone else, but I've tweaked it to work for my needs. Now--I'd like to fix the bad syntax of 'for(i in bits)', but when I've tried what I thought would work, it does not work.
for (i = 0; i < bits; i++) {etc...};
I thought that would work, it does not work. Here is the full script...
function breadcrumbs() {
'use strict';
/*jslint plusplus:true*/
/*jslint browser:true*/
var sURL, bits, x, stop, output, i, y, chunkStart;
sURL = String();
bits = {};
x = 0;
stop = 0;
output = "";
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 (i in bits) {
output += "<a href=\"";
for (y = 1; y < x - i; y++) {
output += "../";
}
bits[i] = decodeURIComponent(bits[i]);
output += bits[i] + "/\">" + bits[i] + "</a> | ";
}
document.write(output + document.title);
}