Latest web development tutorials

HTML onload event properties

HTML Event Attributes HTML Event Attributes

Examples

When you run JavaScript after the document has finished loading the script:

<body onload="load()">

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support onload event attributes.


Definition and Usage

onload attribute triggered after the document object has finished loading.

onload commonly used in <body> element, used to specify the script (including images, script, css files, etc.) is executed after the page is fully loaded.


Differences between HTML 4.01 and HTML5

None.


grammar

<elementonload=" script ">

Property Value

描述
script 规定该onload事件触发时执行的脚本。


HTML Event Attributes HTML Event Attributes