HTML onload Event Attribute

Example

Definition and Usage

The onload attribute fires when an object has been loaded.

onload is most often used within the <body> element to execute a script once
a web page has completely loaded all content (including images, script files, CSS files, etc.).
However, it can be used on other elements as well (see "Supported HTML tags"
below).

The onload attribute can be used to check the visitor's browser type and browser
version, and load the proper version of the web page based on the information.

The onload attribute can also be used to deal with cookies (see "More Examples"
below).

Web Certificates

W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content.
While using this site, you agree to have read and accepted our terms of use,
cookie and privacy policy.
Copyright 1999-2018 by Refsnes Data. All Rights Reserved.Powered by W3.CSS.