Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Saturday, 18 July 2015

In this article I will explain how to disable browser back button after logout in asp.net using JavaScript. Normally when we press back button it will redirected to previous page. So to avoid this we have to disable the browser back button.



Javascript Code for Disable Browser Back Button:
<script type = "text/javascript" >
    function preventBack() { window.history.forward(); }
    setTimeout("preventBack()", 0);
    window.onunload = function () { null };
</script>

Full Source Code for Sample Application:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>


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



</head>
<body> 
    <form id="form1" runat="server">
    <fieldset style="width:350px"><legend><strong>Disable Browser Back button Using javascript</strong></legend>
    <div style="background: maroon;color: White; font-weight:bold;">
    <br />
   Example: Disable Browser Back button link after logOut using javascript.
    <br />
     <br />
    </div></fieldset>
    </form>
</body>
</html>

0 comments:

Post a Comment