There are many cases where we have to disable the back button of the browser.
Here, the following code will help you to make your back button disable.
HTML:
<body onload="disableBackOnLoad(); ">
Now the back button is disabled
</body>
SCRIPT:
function disableBackOnLoad () {
window.location.href += "#";
setTimeout("changingUrl()", "50");
}
function changingUrl() {
window.location.href += "1";
}
// If you want to skip the auto-positioning at the top of browser window,you can add the below code:
window.location.hash=' ';
var storedHash = window.location.hash;
window.setInterval(function () {
if (window.location.hash != storedHash) {
window.location.hash = storedHash;
}
}, 50);
This will help you to disable your browser's back button.
Tested in all major browsers including IE. Demo attached please have a look!
0 Comment(s)