How to disable browser's back button with JavaScript?

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.