0

I am trying to change messge “Changes you made may not be saved.” on leaving the page.I am using window.onbeforeunload for this.

  • in modern browsers, you can not - see https://stackoverflow.com/questions/37782104/javascript-onbeforeunload-not-showing-custom-message (it applies to more than chrome) – Jaromanda X Jul 31 '18 at 05:41
  • 1
    Possible duplicate of [How can I override the OnBeforeUnload dialog and replace it with my own?](https://stackoverflow.com/questions/276660/how-can-i-override-the-onbeforeunload-dialog-and-replace-it-with-my-own) – Makyen Jul 31 '18 at 05:43

1 Answers1

5

Depending on which browsers you are referring to, you cannot change this message.

I assume you are referring to Chrome in this instance, which removed support for changing the beforeunload message as far back as v51: Chrome v51 Deprecations

The main reason it was removed was due to scammers using the message to trick people so Google made it always the same message to avoid confusion.

With this change, Chrome will be consistent with Safari 9.1 and later, as well as Firefox 4 and later.

Simon K
  • 2,762
  • 1
  • 11
  • 20
  • 1
    FYI - firefox shows the message `This page is asking you to confirm that you want to leave - data you have entered may not be saved.` – Jaromanda X Jul 31 '18 at 05:43
  • If you have something new, please post an answer on the Chrome-specific canonical question that is linked in comments on the question instead of answering a duplicate question. – Makyen Jul 31 '18 at 05:47
  • Thank you for replying simon.I am using google chrome browser.Is there any other way we can do this – Ravikiran Gambhire Jul 31 '18 at 06:18
  • Nope, otherwise scammers would still have a way of doing this. – Simon K Aug 01 '18 at 00:07