Close modal on browser back and then erase the forward state - Javascript Browser Object Model

Javascript examples for Browser Object Model:History

Description

Close modal on browser back and then erase the forward state

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*  w w  w. j a va  2 s  .c  om*/

history.pushState(null, null, 'no-back-button');
window.addEventListener('popstate', function(event) {
  history.pushState(null, null, 'no-back-button');
});

    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials