Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Browser Back Button

  • No replies
  • 1 has this problem
  • 12 views
  • Last reply by JP

more options

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.

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.

All Replies (1)

more options

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>