0

I have laravel project with react components.

There is a form on one page and I want to have a modal window displayed with "Save changes Yes/No" message, while user is closing the page.

As soon as I know this can be done in two ways:

  1. By using Prompt from react-router package, but it seems that this won't work for me since I connect react component inside the laravel blade template, thus I don't use react-router.
  2. By using the "beforeunload" event. Modern browsers don't support adjustable messages for the confirmation window and I need to display the adjustable message ("Save changes?").

Does anybody know another way how to track the page closing (or switching to another page) and display a popup window with custom text? Is that possible to display a custom modal window instead of the default confirmation one?

dan
  • 1
  • 2
  • Does this answer your question? [Detect browser or tab closing](https://stackoverflow.com/questions/3888902/detect-browser-or-tab-closing) – StealthTrails Dec 02 '22 at 11:16

0 Answers0