Translate

Friday, 14 July 2017

prevent browser back button in any browser


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






CurrentPage
----------------------

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CurrentPage.aspx.cs" Inherits="CurrentPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type = "text/javascript" >
        function preventBackButton() {
            window.history.forward();
        }
        setTimeout("preventBackButton()", 0);
        window.onunload = function () { null };
</script>
</head>

<body>
    <form id="form1" runat="server">
    <div>
    <a href="NewPage.aspx">New Page</a>
 
    </div>
    </form>
</body>
</html>




-----------------

NewPage

---------------------

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="NewPage.aspx.cs" Inherits="NewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
      <script type = "text/javascript" >
          function preventBackButton() 
          {
              window.history.forward(); 
           }
           setTimeout("preventBackButton()", 0);
          window.onunload = function () { null };
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    
    <a href="CurrentPage.aspx">CurrentPage</a>
    </div>
    </form>
</body>
</html>


No comments:

Post a Comment