This event is fired when an object has been loaded. This event is used mostly with the body element to execute a script, after the page loaded all content (including images, script files, CSS files, etc.), this event will be fired. It also help users to deal with the cookies.
Syntax
<element onload="script">
Attribute value :
script : This script will be run on onloaded.
Example :
HTML Code :
<html>
<head>
</head>
<body onload="onloadFunction()">
<h1>Hello World!</h1>
</body>
</html>
javascript code :
<script>
function onloadFunction() {
alert("Page is loaded");
}
</script>
Output :
Alert-box will pop-up with message "Page is loaded"
0 Comment(s)