returnValue property

Gets or sets a value that indicates whether to warn the user prior to navigating away from a page.

HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 5.10.10Internet Explorer 9




p = object.returnValue


Property values

Type: Variant

Error Message

Display Error Message before unloading the document.

false (false)

Display a default warning dialog box.

true (true)

Default. Unload the document without warning the user.

Standards information


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.

The improved warning dialog of Internet Explorer 9.

See also