How to disable back button in browser using javascript

Here is the javascript code that will help you disable back button in your web browser.

There are times while developing a website, we need to disable back button in browser. Most common example of this is found in Online Banking Websites.

Most of the time the back button is disabled because a user can hit back and navigate from the page and forget to logout.

Given below code in Java script that will disable the working of Back button in Browser:

<SCRIPT type="text/javascript">
window.history.forward();
function noBack() { window.history.forward(); }
</SCRIPT>
</HEAD>
<BODY onload="noBack();"
onpageshow="if (event.persisted) noBack();" onunload="">

Note: If you want to stop user navigating back from Page 2 to Page 1 then the code here is placed in the head section of Page 1.

Advertisements

Share on Google+Share on Google+

How to disable back button in browser using javascript

Posted on: October 2, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: How to disable back button in browser using javascript  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads