// Dynamic Breadcrumbs // Written by Harry Love // Email: hlove@u.washington.edu // Use at your own risk. // Feel free to use, personalize, improve, and distribute. // Last update: November 7, 2002 // To place breadcrumbs in your page, save this // file to a directory that makes sense to you. // Link to it in the portion of your web page. // In the portion of your page, /* paste the following line of code: DO NOT COPY THIS LINE */ // BEGIN BASIC CUSTOMIZATION // Starting Point: 1 = domain, 2 = 1st directory, 3 = 2nd directory, etc. // Must be specified as an integer; no floating point numbers. // ***Note***: If the starting number is greater than the number of // directories you have, the URL will be undefined. var startPoint = 1; // idea from Hassan Schroeder // Separator: set the character(s) that will be used to // separate each of the breadcrumb links. // Set the space in between each link by // specifying a number of non-breaking spaces ( ). // The default separator is a "greater than(>)" symbol (>). var sep = " | " // Starting Name: setting startName to "domain" will // use the full domain name (www.yourdomain.com). // Any other text will be used literally. // E.g., specifying "Home" will use "Home" as the first // link in the chain. // ***Note***: if startPoint is greater than 1, it will start // the chain at a point beyond the domain. startName will // be used for the name of the first link, regardless of where it // starts. var startName = "HOME"; // Uppercase or lowercase directory names? If // uppercase is set to yes, the first character // in each of the directory names will be capitalized. // If allUppercase is set to yes, the entire directory // name will be capitalized for each directory. var uppercase = "no"; var allUppercase = "yes"; // Endpoint: how do you want the script to handle a // URL that ends in a directory name? E.g., if the URL // is http://www.mydomain.com/start/, do you want the // script to write the name of the directory or the // title of the default document in this directory? // You have 2 choices: directory or title. var endPoint = "title"; // END BASIC CUSTOMIZATION var d=document; var url = d.location.href; var endChar = url.substr(url.length-1); // Replace the "//" in "http://www.mydomain.com" with "/" and store that in the url variable. url=url.replace("//","/"); // Split the URL into segments and store them in an array using "/" as a delimiter. // According to the variables, specify upper- or lowercase directory names. var urlArray=url.split('/'); var urlL = urlArray.length; var linkName=new Array(); if(uppercase=="yes"&&allUppercase=="no") { var lowercase; for(x=2;x'+startName+''); // If there are more directories, use this code. // Otherwise, exit. if(urlL>2) { // Loop through the remaining segments of the array. for(x=startPoint+1;x'+linkName[x]+''); break; } else { // This is the last segment. // Write it to the page, then exit. d.write(sep+''+d.title+''); break; } } // Otherwise, use this code... else { // Add the current start segment to the previous start segment // and add a backslash to the end. start=start+urlArray[x]+"/"; // Write the link to the page with sep as a separator. d.write(sep+''+linkName[x]+''); } } // Otherwise, this is the last segment... else { // Add the current segment to the previous segment // but do not add a backslash. start=start+urlArray[x]; // If this segment is a directory... if(endChar=="/") { // Write the last segment to the page with sep as a separator. d.write(sep+''+linkName[x]+''); } // Otherwise this segment is a filename... else { // Write the link to the page with sep as a separator. // Use the document title for the segment name. d.write(sep+''+d.title+''); } } } } }