Advertisement
Home Open Editor ❯

HTML onbeforeunload event Attribute

Example

<body onbeforeunload="return myFunction()">

Try this code ❯

Meaning

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


Standard Syntax

<element onbeforeunload="script">


Advertisement

Attribute Values

Value Description
script Specifies the script to be run on onbeforeunload

Technical Details

Supported HTML elements:

<body>
Home Open Editor ❯
Advertisement