Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This thing works fine but after redirecting to "Page2.htm" try pressing and holding backspace for few seconds, it goes back to "page1.htm"

This is code you saw below

<script>
      $(document).ready(function(){
          function disableBack() {window.history.forward()}
          window.onload = disableBack();
  	  window.onpageshow = function(evt) {if(evt.persisted) disableBack()}
      });
</script>


What I have tried:

I had more try for this topic but no correct getting answer
Posted
Updated 27-Feb-17 23:51pm
Comments
F-ES Sitecore 28-Feb-17 7:00am    
People have been asking this question for over a decade, please do basic research before asking a question such as using Google. In those 10+ years the answer has still not changed, and it isn't going to change for the next 10+ years either.

1 solution

Use of this code : 

// for script code:
<script type="text/javascript" language="javascript">
window.history.forward(1);
document.attachEvent("onkeydown", functionName);
function functionName()
{
switch (event.keyCode)
{
case 116 : // F5;
event.returnValue = false;
event.keyCode = 0;
window.status = "We have disabled F5";
break;
}
}
</script>
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();
   }
 
Share this answer
 
v2

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