javascript disable back button code example
Example 1: disable back button in browser
<script type="text/javascript"> function preventBack() {window.history.forward();} setTimeout("preventBack()", 0); window.onunload = function () {null};</script>
Example 2: how to disable back js
history.pushState(null, null, null);
$(window).on("popstate", function (event) {
if (!event.originalEvent.state) {
history.pushState(null, null, null);
return;
}
});