Wednesday, April 18, 2012

Disabling the back button on the Browser Using Javascript

In this post I am going to explain about how to disable the back button on the browser using the Javascript.Recently one of my project I need to implemented this and I want to share with you.

To do this We need to create the Aspx page as follows :

<html xmlns="">
<head runat="server">
    <script type = "text/javascript" >
        function disableBackButton() {
        setTimeout("disableBackButton()", 0);
<body onload="disableBackButton()">
    <form id="form1" runat="server">
    Hi !!!!! Press Back Button and see for this Page

If you observer the above code I am calling the Javascript function called “disableBackButton()” on the page load.In this I have used the window.history.forward() Function. This means it is The history object contains the URLs visited by the user (within a browser window).The history object is part of the window object and is accessed through the window.history property.SetTimeout is the method which call a method when a timeout expire.

OutPut : 

No comments:

Post a Comment