How To Disable Back function in browser?


Disable Back function in browser

Sometimes we need to disable back function of our web page.
So, I am giving the code To disable back function. just write below javascript code in your head tag.

Code :



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


Then put the below in body tag.

Code:



<body onload="disableBackButton()">


Thank You.

Reference: http://blog.dotnetsquare.com/java-script/disable-function-browser/


Comments



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: