Browser Back Button
In our banking web site we need to show a pop up while the end user clicks the back button. I have implemented the solution in javascript and the solution works in other browser, but in firefox when we need to click the browser back button twice or thrice to show the pop up. Need help to solve this issue.
Wszystkie odpowiedzi (1)
You could try this solution from stack overflow (ddg.gg/javascript confirmation back button). The dialog opens when I press the back button once. Put this in a file and call `firefox index.html`.
<meta charset="UTF-8"> <title>JavaScript Hello World Example</title> <script> if (window.history && history.pushState) { addEventListener('load', function() { history.pushState(null, null, null); // creates new history ent> addEventListener('popstate', function() { var stayOnPage = confirm("Would you like to save this draft> if (!stayOnPage) { history.back() } else { history.pushState(null, null, null); } }); }); } </script>