Rechercher dans l’assistance

Évitez les escroqueries à l’assistance. Nous ne vous demanderons jamais d’appeler ou d’envoyer un SMS à un numéro de téléphone ou de partager des informations personnelles. Veuillez signaler toute activité suspecte en utilisant l’option « Signaler un abus ».

Learn More

Browser Back Button

  • Aucune réponse
  • 1 a ce problème
  • 16 vues
  • Dernière réponse par 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.

Toutes les réponses (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>