Click here to Skip to main content
15,886,026 members
Articles / Programming Languages / Javascript
Tip/Trick

Regarding back button after signout

Rate me:
Please Sign up or sign in to vote.
3.17/5 (6 votes)
20 Nov 2011CPOL 20.3K   4   8
Regarding back button after signout
In your webpage after signout and pressed back button, the previous session will remain the same. So use the below JavaScript. So that previous session will open.

For example: In our CodeProject.com after signout press back button .. your previous session will remain the same.


<script type="text/javascript">
        function noBack()
         {
             window.history.forward()
         }
        noBack();
        window.onload = noBack;
        window.onpageshow = function(evt) { if (evt.persisted) noBack() }
        window.onunload = function() { void (0) }
    </script>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Junior) Hp finsoft
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralReason for my vote of 3 It is good. I am searching it from a... Pin
Danish Shamshad23-Nov-11 1:24
Danish Shamshad23-Nov-11 1:24 
Reason for my vote of 3
It is good. I am searching it from a long time
GeneralReason for my vote of 1 u always can choose to go to step ba... Pin
itaitai22-Nov-11 22:39
professionalitaitai22-Nov-11 22:39 
GeneralRe: not for every page that i have given these code..when we are... Pin
vinoth kumar rajendran24-Nov-11 15:25
vinoth kumar rajendran24-Nov-11 15:25 
GeneralIs this function to call on sign out link/button Pin
mayur csharp G21-Nov-11 1:30
mayur csharp G21-Nov-11 1:30 
GeneralRe: no need of calling in signout button just we want to write t... Pin
vinoth kumar rajendran24-Nov-11 15:23
vinoth kumar rajendran24-Nov-11 15:23 
GeneralReason for my vote of 2 nice Pin
Mahesh Sanika16-Nov-11 1:00
Mahesh Sanika16-Nov-11 1:00 
GeneralReason for my vote of 4 Good one :) Pin
jawed.ace9-Nov-11 20:09
jawed.ace9-Nov-11 20:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.