...

View Full Version : History menu for your site.



x_goose_x
09-03-2002, 03:35 AM
This script keeps a history of the pages previously visited on your site with links pointing to the page.

Just add the following to your head:



<script>
pagetitle = "Local News Page"; // This is what appears in the history list
</script>
<script src="history.js"></script>


and add the following to where you want the history list to appear:



<div id="Histbox"></div>


and put the following in a .js file named history.js:



frstvst = "Welcome!"; // If there is no history, this should be displayed.
histlen = 5; // Number of sites back to keep in history
splitter = " - "; // Enter what you'd like to be put in between the items in the history list (HTML) use <br> to put each on a seperate line.

kookz = document.cookie;
kookz2 = kookz.split(",");
kookz3 = new Array();

function loader() {
pgtitle = pagetitle+"-"+location.href;
if (kookz) {
y = 0;
z = kookz2.length;
for (x=0; x<z; x++) {
if (kookz2[x]==pgtitle) {
y++;
z--;
}
if (kookz2[x+y]) {
kookz3[x] = kookz2[x+y];
}
}
if ((histlen-kookz3.length)<0) {
t = kookz3.shift();
}
divhtml = "";
for (x=0; x<kookz3.length; x++) {
dash = kookz3[x].indexOf("-");
histhref = kookz3[x].substring(dash+1,kookz3[x].length);
histlink = kookz3[x].substring(0,dash);
divhtml += "<a href='"+histhref+"'>"+histlink+"</a>";
if ((x+1)<kookz3.length) {
divhtml += splitter;
}
}
document.getElementById("Histbox").innerHTML = divhtml;
kookz3[kookz3.length] = pgtitle;
document.cookie = kookz3;
}else {
document.cookie = pgtitle;
document.getElementById("Histbox").innerHTML = frstvst;
}
}

window.onload = loader;


I've tested it in IE6 and Moz1.1

I will also attach a zip file containing the appropriate files.

See it in action:

History test (http://pages.infinit.net/mvideos/history/four.htm)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum