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.
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.
In the html-code of all your pages insert after the <body> tag (or any other place you like) following:
The third parameter is the path to RestoreLastVisitedPage.js file.
So if you don’t need any customization you can only insert:
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.
You can see how it works at my personal site www.thebridge.ru
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.
Latest version 1.0 – 29 Oct 2007
http://sourceforge.net/projects/dslvp/