Tuesday, January 21, 2014

Disable Browser Back Button Functionality using JavaScript


In this article, I am discussing how to prevent user from navigate to previous page using back button of the browse.
One cannot disable the browser back button functionality only thing that can be done is prevent them.
Below is the JavaScript snippets that needs to be placed in the head section of the page where you don’t want the user to revisit using the back button

<script type = "text/javascript" >
   function preventBack(){window.history.forward();}
    setTimeout("preventBack()", 0);
    window.onunload=function(){null};
</script>

No comments:

Post a Comment