Auto Redirect to Last Visited Page on Website

The Idea

The idea of this script I’ve encountered when reread a book of Jef Raskin "The Humane Interface: New Directions for Designing Interactive Systems". In the section about resuming interrupted tasks he advices to restore them in the place where the user left off. In relation to web sites it means that when you return to some website the best is to return you to the page where you were last time, rather than to the main (home) page. Moreover if site is well designed you can navigate to the main page in one click.

I highly recommend you this book if you want to develop good user interfaces.

Purpose

The purpose of this script is to redirect user to the page where he left your site at the last visit. Redirect is only performed if user enters the main page of your site from any other site. Thus if user enters your site by direct link to a content from any search engine or another site, redirect is not performed allowing user to see appropriate content.

Installation, parameters and usage

  1. Download and save script into your web server document directory. For example my server is www.thebridge.ru and I have stored script in the /httpddocs/wp-content/themes/pure-12/ directory.
  2. In the html-code of all your pages insert after the <body> tag (or any other place you like) following:

    <script>
    var dsLVPURLMainPage = "http://www.thebridge.ru/";
    var dsLVPNotification = "You have been automatically redirected to last visited page on the site.";
    </script>
    <script src="http://www.thebridge.ru/wp-content/themes/pure-12/RestoreLastVisitedPage.js" type="text/javascript">
    </script>
    where you should replace highlighted text with your values. The first value dsLVPURLMainPage is URL of your site main page. If your site main page coincides with site domain name (as in example) then you can omit this setting. Second parameter dsLVPNotification is also optional. This is the text of the message that you can show to a user when he is automatically redirected. To use it you should use
    document.write(dsLVPMessage)
    javascript code in any place you want message to appear.

    The third parameter is the path to RestoreLastVisitedPage.js file.

    So if you don’t need any customization you can only insert:

    <script src="http://path-to-your-location/RestoreLastVisitedPage.js" type="text/javascript"></script>

  3. There is one more parameter that you can use: dsLVPDisabled. If this variable is set to any value then current page will not be remembered. This option is useful for the pages that are dynamically generated by data that is sent by HTTP POST requests. It is not good idea to return user to such pages because he usually receives an error message there. So to disable storing of current page add following code before the <script> tag with main code include.

    <script>var dsLVPDisabled=1</script>

Demo

You can see how it works at my personal site www.thebridge.ru

Download

The code is hosted at sourceforge.net You can download all of it files at http://sourceforge.net/project/platformdownload.php?group_id=209009&sel_platform=5078. Latest version is only available there.

Changelog

Latest version 1.0 – 29 Oct 2007

Forums and Bug Reports

http://sourceforge.net/projects/dslvp/


SourceForge.net Logo
Also look at my other project: HealthKeeper
And visit my personal site: estacion