HTML onloadEvent Attribute

HTML 事件属性HTML Event Attributes

Example

Run JavaScript after the document has finished loading:

<body onload="load()">

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the onload event attribute.


Definition and Usage

The onload attribute triggers when the document object has finished loading.

The onload attribute is commonly used within the <body> element to execute a specified script after the page has fully loaded (including images, scripts, CSS files, etc.).


Differences between HTML 4.01 and HTML5

None。


Syntax

<element onload="script">

Attribute Values

Value Description
script Specifies the script to be executed when the onload event is triggered.


HTML 事件属性HTML Event Attributes Other Extensions