Name
BeforeUnloadEvent — Event object for unload events
Inherits from
Event
Synopsis
The unload event is triggered on a Window object just before
the browser navigates to a new document, and gives a web application
the opportunity to ask the user if he is really sure he wants to
leave the page. The object passed to unload event handler functions
is a BeforeUnloadEvent object.
If you want to require the user to confirm that he really wants to
leave the page, you do not need to, and should not, call the
Window.confirm() method. Instead,
return a string from the event handler or set the returnValue of this event object to a
string. The string you return or set will be presented to the user
in the confirmation dialog the user sees.
Properties
stringreturnValueA message to be displayed to the user in a confirmation dialog before navigating away from the page. Leave this property unset if you do not want to display a confirmation dialog.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access