Introduction:
In this article i am going to explain about how to disable avoid browser back button functionality using javascript asp.net.
Main:
We can easily avoid the navigation of previous page(using browser back button) using the below simple script,
<script type = "text/javascript" >
function InvalidBackButton()
{
window.history.forward();
}
setTimeout("InvalidBackButton()", 0);
</script>
<script type = "text/javascript" > function InvalidBackButton() { window.history.forward(); } setTimeout("InvalidBackButton()", 0); </script> |
If you wants in Code Behind,
string local_exestring = "<SCRIPT language=javascript>n";
local_exestring += "window.history.forward(1);n";
local_exestring += "n";
<strong>ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "Script",local_exestring );</strong>
string local_exestring = "<SCRIPT language=javascript>n"; local_exestring += "window.history.forward(1);n"; local_exestring += "n"; <strong>ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "Script",local_exestring );</strong> |
Conclusion:
Hope this helps,
Happy Coding.
Great blog! I really love how it’s easy on my eyes and the details are well written. I am wondering how I could be notified whenever a new post has been made. I have subscribed to your rss feed which must do the trick! Have a nice day!