English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Wenn eine Ressource und ihre abhängigen Ressourcen vollständig geladen sind, wird das load-Ereignis ausgelöst.
JavaScript wird sofort nach dem Laden der Seite ausgeführt:
<!DOCTYPE html> <html> <head> <title>Verwendung der onload-Eigenschaft von HTML (Grund教程网 oldtoolbag.com)</title> <script> function myFunction() { alert("Seite wurde geladen"); } </script> </head> <body onload="myFunction()"> <h1>Hello World!</h1> </body> </html>Test see ‹/›
IEFirefoxOperaChromeSafari
All major browsers support the onload event attribute.
The onload attribute is triggered after the object is loaded.
Once the web page has completely loaded all content (including images, script files, CSS files, etc.), onload is typically used within the <body> element to execute scripts. However, it can also be used on other elements (see the following 'Supported HTML Tags').
The onload attribute can be used to check the visitor's browser type and version, and load the correct version of the web page based on this information.
The onload attribute can also be used to handle cookies.
No differences.
<element onload="script">
Value | Description |
---|---|
script | Specifies the script to be executed when the onload event is triggered. |