How to disable back button using JS

Method 1:

<!-- Script by -->
<script type="text/javascript">
	function noBack()
<!-- Script by -->
<!-- Script by -->
 <body onload="noBack();" onpageshow="if (event.persisted) noBack();" onunload="">
  <center>  <a href="test.php"><H2>HIOX</H2></a>
    <p><b>When ever you have to be click <b>HIOX</b>,the back button will be disabled.</b>
	<div style="font-size: 10px;color: #dadada;" id="dumdiv" align=center>
<a href="" id="dum" style="text-decoration:none;color: #dadada;">©h</a></div>

Method 2:

Following is the code to open webpage in a new window have no toolbar (Back/Next buttons). ("",

Also it is possible to disable the right click on any webpage using Javascript. Add following code in the webpage.

 <body oncontextmenu="return false;">

This is another technique to disable the back functionality in any webpage. We can disable the back navigation by adding following code in the webpage. Now the catch here is that you have to add this code in all the pages where you want to avoid user to get back from previous page. For example user follows the navigation page1 -> page2. And you want to stop user from page2 to go back to page1. In this case all following code in page1.

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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s