1. You MUST use underscores to seperate file names like file_name.asp. this program will remove the underscores in the breadcrumbs.
2. You will want to put the files and folders in a structured envirnoment.
default.asp
folder1 - default.asp
folder1 - file_name1.asp
folder1 - file_name2.asp
folder2 - default.asp
folder2 - file_name2.asp
folder2 - contact_us.asp
Then create a crumbs.js file and here is the code that goes inside of it:
- Code: Select all
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].replace(/_/g, ' ').toLowerCase() + "</a> > ";
}
var sPage = location.href.substring(location.href.lastIndexOf('/') + 1);
if(sPage.length > 0)
{
if(sPage.indexOf('.') > 0)
{
sPage = sPage.substring(0, sPage.indexOf('.')).toLowerCase();
if(sPage != 'default' && sPage != 'index')
output += sPage.replace(/_/g, ' ');
}
}
document.write(output);
}
reference the crumbs.js from the page like this:
- Code: Select all
<script language="JavaScript" src="crumb.js"></script>
and add an element inside the page like this:
- Code: Select all
<td class="info"> <script language="JavaScript">breadcrumbs();</script></td>
