JavaScript to Disable Browser Back Button

1. Disable the page cache using the script on the server-side. The code is given below:

Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.AddHours(-1);
Response.Expires = 0;
Response.CacheControl = "no-cache";

2. Disable the page cache to make the browser no longer save the cache of web pages on the client-side, mentioned as below:

<head>
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
</head>

3. Use the javascript on the client-side to realize the forward effect, this counteracts the action of the user’s, clicking the back button. See the code given below:

<script type="text/javascript">
   window.history.forward(1);
</script>

For more details you may visit my blog:

Javascript to Disable Browser Back Button

Ebook Download
View all
Learn
View all