how to disable the browser back button in javascript.

how to disable the browser back button in javascript.

Dont!

You can't, and you shouldn't.

every other approach / alternative will only cause really bad user engagement.

Put This script on head of your page and change 'pagename' to your page name. but anyway , here is a trick :

<script type = "text/javascript" >     history.pushState(null, null, 'pagename');     window.addEventListener('popstate', function(event) {     history.pushState(null, null, 'pagename');     });     </script>