- onload is most frequently used within the
<body>element to perform a script once a website has fully loaded (including script files, images, CSS files, etc.).
- The onload event shall be used to verify the type of the visitor's browser and version of the browser, and then load an individual web page version based on the information.
- The onload event can deal with cookies.
onload Event Explained
window.onload function is widely supported by popular browsers. It begins as soon as the resource is loaded.
- Simplistic design (no unnecessary information)
- High-quality courses (even the free ones)
- Variety of features
- Nanodegree programs
- Suitable for enterprises
- Paid certificates of completion
- Professional service
- Flexible timetables
- A variety of features to choose from
- Professional certificates of completion
- University-level courses
- Multiple Online degree programs
- Great user experience
- Offers quality content
- Very transparent with their pricing
- Free certificates of completion
- Focused on data science skills
- Flexible learning timetable
Learn Event Syntax
object.onload = () => sampleScript();
The addEventListener() method is supported by Internet Explorer 9 and newer versions only.
Code Examples: Best Practice
In this example, an
<img> element is signed onload. Alert
Image is successfully loaded is displayed after an image is loaded:
<img src="https://cdn.bitdegree.org/learn/pom-laptop.png?raw=true" onload="ImageLoad()" width="120" height="120">
Now, in this example, we deal with cookies by using the onload event:
Latest Udacity Coupon Found:
75% OFF COURSES
Udacity Black Friday Offer
The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!