Click here to Skip to main content
15,915,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear one,

How to browser Back Button Disabled after LOGOUT from mail.
like Gmail,Yahoomail.
Using java script and asp.net,C#
Note: WithOut Page Loading.


sent with COde.

By mohan.
Posted
Updated 4-Nov-11 21:44pm
v3

After clicking logout uexecute the bellow code in server side



JavaScript
<script type = "text/javascript" >
   function preventBack(){window.history.forward();}
    setTimeout("preventBack()", 0);
    window.onunload=function(){null};
</script>
 
Share this answer
 
v2
On code behind write this:

Collapse | Copy Code

C#
protected void Page_Load(object sender, EventArgs e)
   {
      
     HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
     HttpContext.Current.Response.Cache.SetNoServerCaching();
     HttpContext.Current.Response.Cache.SetNoStore();
    
 
   }




and on client side write something like this:

Collapse | Copy Code

JavaScript
<script type="text/javascript" language="javascript">
window.history.forward(1);
document.attachEvent("onkeydown", my_onkeydown_handler);
function my_onkeydown_handler()
{
switch (event.keyCode)
{
case 116 : // F5;
event.returnValue = false;
event.keyCode = 0;
window.status = "We have disabled F5";
break;
}
}
</script>
 
Share this answer
 
v3
 
Share this answer
 
 
Share this answer
 
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900