How to disable browser's back button with JavaScript?

JavascriptObject Oriented ProgrammingFront End Technology

To disable web browsers’ back button, try to run the following code. This is the code for current HTML page,


      <title>Disable Browser Back Button</title>
      <script src = ""></script>
      <script src = ""></script>
      <a href = "newpage.html">Next Page</a>
      $(document).ready(function() {
         function disablePrev() { window.history.forward() }
         window.onload = disablePrev();
         window.onpageshow = function(evt) { if (evt.persisted) disableBack() }

The following is the code for newpage.html,

      Go to back page using web browser back button.
Published on 01-Mar-2018 06:34:28