martes, 28 de mayo de 2019

Disable Browser Back Button Script



1- Must be placed in the HEAD section of the Page

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

For illustration purposes, two Pages are used Login and Home.

Disable Browser Back Button Functionality using JavaScript

The Disable Browser Back Button Script is placed in the HEAD section so that User cannot access the Login page using Browser Back button from Home page.

2 - now body </body>

<body>
    <h3>Login</h3>
    <hr />
    <a href = "Home.htm">Redirect to Home</a>
</body>

the code will look like this

<head>
    <title>Login</title>
    <script type="text/javascript">
        function preventBack() { window.history.forward(); }
        setTimeout("preventBack()", 0);
        window.onunload = function () { null };
    </script>
</head>
<body>
    <h3>Login</h3>
    <hr />
    <a href = "Home.htm">Redirect to Home</a>
</body>
</html>

0 comentarios:

Publicar un comentario

Translate = traduce

Nuestros ultimos