Disable the back button in the browser using javascript — To disable web browsers’ back button, try to run the following code.
Stop the browser back button For Example
window.onbeforeunload = function() { return "sorry, Your some work will be lost - really sorry."; };
How to disable the browser back button using JavaScript?
Example 1:
<script type="text/javascript">
function disableBack() { window.history.forward(); }
setTimeout("disableBack()", 0);
window.onunload = function () { null };
</script>
How to Disable Browser Back Button using JavaScript?
Example: 2
window.history.pushState(null, null, window.location.href);
window.onpopstate = function () {
window.history.go(1);
};
Disable the browser back button using JavaScript
Example : 3
<script type = "text/javascript" >
function preventBack() { window.history.forward(); }
setTimeout("preventBack()", 0);
window.onunload = function () { null };
</script>
Disable Browser Back Button Functionality using JavaScript
index Page(index.html)
<script type="text/javascript">
function preventBack() { window.history.forward(); }
setTimeout("preventBack()", 0);
window.onunload = function () { null };
</script>
<h3>index</h3>
<hr />
<a href="dashboard.html">Redirect to dashboard</a>
Dashboard Page (dashboard.html)
<h3>Dashboard</h3>
<a href="index.htm">Redirect to index</a>
I hope you get an idea about disabling the back button in the browser using javascript.