The onbeforeunload event run when the document is about to be unloaded. This event is used to allow to display a message in a dialog box to inform the user to he/she wants to stay or leave the current page.
<element onbeforeunload = "script">
Attribute Value: This attribute contains single value script and it runs when onbeforeunload event called. This event attribute is supported by <body> tag.
Supported Browsers: The browser supported by onbeforeunload attribute are listed below:
- Google Chrome
- Internet Explorer
- Opera 15.0 and above