Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Montreal, Canada
    Thanked 0 Times in 0 Posts

    History menu for your site.

    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:

    pagetitle = "Local News Page"; // This is what appears in the history list
    <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) {
    			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
    Attached Files Attached Files
    Last edited by x_goose_x; 09-03-2002 at 04:47 AM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts