Thursday, 16 May 2013

disable browser back button


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type = "text/javascript" >
function disableBackButton()
{
window.history.forward();
}
setTimeout("disableBackButton()", 0);
</script>
</head>
<body onload="disableBackButton()">
<form id="form1" runat="server">
<div>
This is First page <br />
<br />
Go to Second page
<br />
<br />
<asp:LinkButton ID="LinkButton1" runat="server"
PostBackUrl="~/Default2.aspx">Go to Second Page
</asp:LinkButton></div>
</form>
</body>
</html>


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

OR

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

<script language="JavaScript1.2">

if (document.all){
document.onkeydown = function (){
var key_f5 = 116; // 116 = F5

if (key_f5==event.keyCode){
event.keyCode = 27;

return false;
}
}
}

</script>

No comments:

Post a Comment