Redirect to Last Page Visited | JavaScriptSource

Redirect to Last Page Visited

Dmitriy Simonchik Nov 2, 2007


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


If you have pages that are dynamically generated by data that is sent by HTTP POST requests, the code below will make sure the current page will not be remembered. To disable storing of the current page, add the following code before the SCRIPT tag where the main code is included:

<script>var dsLVPDisabled=1</script>


Further information can be found online.

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: RestoreLastVisitedPage.js


Paste this code into the HEAD section of your HTML document.


If the redirection message is used, paste this code into the BODY section of your HTML document where you want the message displayed

Leave a Response



tutulmedia Jul 26, 2012

You only need to add the code to each page if you want to add a redirection message (e.g., "you are being redirected").

Lee Nov 13, 2007

I am a simple writer, NOT a programmer, so this question may seem quite silly to you:[br /]Do I understand you correctly, anddo I really have to paste TWO pieces of code in the HEAD section of each and every page in my (enormous!) site? Or does pasting them in the HEAD of my index.htm page suffice?[br /][br /]Thank you - if this is working correctly, it is [i]exactly[/i] what I have been looking for![br /][br /]Kind regards from a rather stormy Amsterdam,

Jan van Erp Nov 9, 2007