A window’s onbeforeunload property may be set to a function that returns a string. If the function returns a string, then before unloading the page, a dialog is shown to have the user confirm that they indeed want to navigate away. The string provided by the function will no longer be shown in the dialog. Rather, a generic string not under the control of the webpage will be shown.


Established standard

Status in Chromium


Removed (tracking bug) in:

  • Chrome for desktop release 51
  • Chrome for Android release 51
  • Android WebView release 51

Consensus & Standardization

After a feature ships in Chrome, the values listed here are not guaranteed to be up to date.



This shipped in Safari 9.1, and has been shipping in Firefox since Firefox 4. Safari considers this a security fix and assigned it CVE-2009-2197 (see https://support.apple.com/en-us/HT206171 ). Approved with the intent https://groups.google.com/a/chromium.org/d/msg/blink-dev/YIH8CoYVGSg/Di7TsljXDQAJ .

Last updated on 2020-11-09