2.3.4.9 onbeforeunload

onbeforeunload of type Function

Occurs prior to a page being unloaded.

To invoke, close the browser window; navigate to another page by entering a new address, selecting a Favorite, or clicking an anchor that refers to another webpage; click the Back, Forward, Refresh, or Home button; invoke anchor.click(), document.write(), document.open(), document.close(), location.replace(), location.reload(), window.close(), window.navigate(), or set a new value of location.href property; submit a form, or invoke form.submit().

Return a string from the event handler to prompt the user with the option of staying on the current page. The statement that appears in the dialog box ("Are you sure you want to navigate away from this page? . . . Press OK to continue, or Cancel to stay on the current page") cannot be removed or altered.

  • Bubbles: Yes

  • Cancelable: Yes

  • Context Info: None

The onbeforeunload attribute extends the following interfaces: