HTML onbeforeunload event Attribute

❮ HTML Event Attributes

Example

<body onbeforeunload="return myFunction()">

Meaning

The onbeforeunload attribute is invoked just before a page or object is unloaded from the user agent.


Standard Syntax

<element onbeforeunload="script">

Browser Support




Status







Attribute Values

Value Description
script Specifies the script to be run on onbeforeunload



Technical Details

Supported HTML elements:

<body>
❮ HTML Event Attributes