Window beforeunload event
26 June 2023 (Updated 26 June 2023)
On this page
In a nutshell
The beforeunload
event is fired when a user is about to leave a webpage. The page is still visible at this point and the navigation away from the page can still be cancelled.
The event is useful for prompting the user to confirm that they want to leave the page when some data they’ve entered is unsaved and will be lost if they navigate away.
Other notes
Sticky activation is required. The user must have interacted with the page for this feature to work.
Links
- Window: beforeunload event – MDN
Tagged:
Web APIs
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment