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="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type = "text/javascript" >
function disableBackButton() {
window.history.forward();
}
setTimeout("disableBackButton()", 0);
</script>
</head>
<body onload="disableBackButton()">
<form id="form1" runat="server">
<div>
Hi !!!!! Press Back Button and see for this Page
</div>
</form>
</body>
</html>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