onload Event in JavaScript
onload Event in JavaScript
The onload event is used with a body tag to execute the script once a page is loaded with all of its content. It is also used to check the visitor browser type and version in order to load the proper web page based on the information.
Used on following elements:-
- body
- iframe
- img
- input
- link
- script
- style
Syntax:-
Its syntax is:- < element onload="my_script" > OR object.onload= function(){my_script} OR object.addEventListener("load", my_script)