Beforeunload
Widely available since 2018-01-29
The beforeunload
event is fired when the current window is about to be unloaded. Typically this is used to display a dialog to confirm if users really want to leave the page when there is unsaved data that would be lost.
Learning resources on MDN
Browser support
- Chrome 1 Released on 2008-12-11
- Chrome Android 18 Released on 2012-06-27
- Edge 12 Released on 2015-07-29
- Firefox 1 Released on 2004-11-09
- Firefox for Android 4 Released on 2011-03-29
- Safari 3 Released on 2007-10-26
- Safari on iOS 1 Released on 2007-06-29
Specifications
- HTML Standard (#the-beforeunloadevent-interface), from HTML Workstream (WHATWG).