Home Javascript How to disable back button in browser using javascript
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

How to disable back button in browser using javascript

Advertisement
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.

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 2, 2013

Related Tutorials

Ask Questions?    Discuss: How to disable back button in browser using javascript  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com