English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Referenzhandbuch

Vollständige Liste der HTML-Tags

HTML onunload-Ereignisattribut

Wenn die Seite geschlossen wird, wird das unload-Ereignis ausgelöst.

HTML Event Attributes

Online-Beispiel

Führen Sie JavaScript aus, wenn das Dokument vom Benutzer deinstalliert wird:

!DOCTYPE html>
<html>
<meta charset="utf-8"> 
<title>Grundausbildung(oldtoolbag.com)</title>
<head>
<script>
function say_goodbye()
{
    alert("Vielen Dank, dass Sie die Grundausbildung besucht haben(oldtoolbag.com)。
}
</script>
</head>
<body onunload="say_goodbye()">
<h1>Welcome to my homepage</h1>
<p>Closing the window or pressing F5 Refresh the page.</p>
</body>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the onunload event attribute

Definition and Usage

The onunload attribute is triggered after the page (or browser window) is unloaded.

onunload occurs when the user navigates away from the page (by clicking a link, submitting a form, closing the browser window, etc.).
Note: If the page is reloaded, the onunload event (and onload event) will also be triggered.

HTML 4.01 and HTML5differences between

No difference.

Syntax

<element onunload="script">

Attribute Value

ValueDescription
scriptSpecifies the script to be executed when the onunload event is triggered.
HTML Event Attributes