How to disable browser back button using JavaScript?


Minifycode 2021-10-03 Viewed 1.4K times Javascript

In this article, how to disable browser back button using JavaScript?

 

Using window.history.forward()

 

<script type = "text/javascript" >  
    function preventBack() { window.history.forward(); }  
    setTimeout("preventBack()", 0);  
    window.onunload = function () { null };  
</script>

How to disable browser back button using JavaScript?
minify code