Gets or sets a value that indicates whether to warn the user prior to navigating away from a page.
Error Messagebefore unloading the document.
Display a default warning dialog box.
Default. Unload the document without warning the user.
- HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 5.10.10
The onbeforeunload event allows you to warn a user who is navigating away from a page or closing the browser. Set the return value to false or a Variant of type String value to cancel the document unload event. You can also return a string or Boolean value from the event handler to display a message to the user, who is asked to confirm that they want to unload the document.
The warning dialog box in Windows Internet Explorer 9 is easier to read than in earlier versions. In the improved dialog box, it is easier to distinguish the default text from text provided by the website, and large buttons clearly indicate how to stay on the page or navigate away.