Tuesday, 20 November 2012

Code For Disable Back Button

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>

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

 <script type="text/javascript">

    function openWindow() {
        //Open a new window with no toolbar
        window.open("http://localhost:4033/pjkt/HowtodisableBACKbutoonOfBroser1.aspx","mywindow","status=1,
toolbar=0");

        }
</script>
<script type="text/javascript">

    function openWindow1() {
        //Open a new window with no toolbar
        window.open("http://localhost:4033/pjkt/CUSTOMPaginginGRidViev.aspx","mywindow","status=1,
toolbar=8");

        }
</script>
<%--<script type = "text/javascript" >
function disableBackButton()
{
window.history.forward();
window.history.backward();
}
setTimeout("disableBackButton()", 0);
</script>--%>
</head>
<body onload="disableBackButton()">
<form id="form1" runat="server">
<div>
This is First page <br />
<br />
Go to Second page
<br />
    <asp:Button ID="Button1" runat="server" Text="Go To second Page
But NotDisable the Back Button " />
<br />

 <input type="button" value="Open Page With Hide Tool Bar"
onclick="openWindow()"/>
 <br />
  <input type="button" value="Open Page Disable The back button"
onclick="openWindow1()"/>
    </div>
</form>
</body>
</html>

No comments:

Post a Comment