Advertisement
Home Open Editor ❯

HTML onbeforeunload 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">


Applies to:

The onbeforeunload attribute can be used on the following element:

Element Attribute
<body> onbeforeunload

Advertisement

Attribute Values

Value Description
script Specifies the script to be run on onbeforeunload
Home Open Editor ❯
Advertisement