Clear Browser History using Javascript
This script needs to put in only on one page, from where you do not want to move back.
<script type="text/javascript"> window.onload = function () { Clear(); } function Clear() { var Backlen=history.length; if (Backlen > 0) history.go(-Backlen); } </script>
Second, if you do not want the user to move to the back page, you can do as below. This script needs to be repeated at every page.
<script type="text/javascript"> if(window.history.forward(1) != null) window.history.forward(1); </script>
Not Working in firefox......
ReplyDeleteDear Saurab, You could try the following trick if you want to disable the browser back button:
ReplyDelete<script type = "text/javascript" >
function disableBackButton()
{
window.history.forward();
}
setTimeout("disableBackButton()",0);
</script>
<body onunload="disableBackButton()" onload="disableBackButton()">
</body>
Alternatively, Refer these links:
http://www.dotnetvishal.com/2012/11/disable-browser-back-button.html
http://forums.asp.net/p/1161997/1923379.aspx
Thanks Vishal....
DeleteIt works perfectly, thanks Ranjan!
ReplyDeletePerfect Code to disable back button.....Thanks
ReplyDelete