Beforeunload
Limited availability
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.
To learn more, see
Window: beforeunload event at MDN.
Compatibility
- Chrome 119 Released on 2023-10-31
- Chrome Android 119 Released on 2023-10-31
- Edge 119 Released on 2023-11-02
- Firefox 6 Released on 2011-08-16
- Firefox for Android 6 Released on 2011-08-16
- Safari 11 Released on 2017-09-19
- Safari on iOS ❌ Search for bugs Search for standards position
Baseline availability blocked since November 2023 by Safari on iOS (12 months)
Specifications
- HTML Standard (#the-beforeunloadevent-interface), from HTML Workstream (WHATWG).