Шукати в статтях підтримки

Остерігайтеся нападів зловмисників. Mozilla ніколи не просить вас зателефонувати, надіслати номер телефону у повідомленні або поділитися з кимось особистими даними. Будь ласка, повідомте про підозрілі дії за допомогою меню “Повідомити про зловживання”

Learn More

Ця тема перенесена в архів. Якщо вам потрібна допомога, запитайте.

Browser Back Button

  • Відповіді відсутні
  • 1 має цю проблему
  • 12 переглядів
  • Остання відповідь від 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.

Усі відповіді (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>