Horje

How to use onload on an <img> element. Alert "Image is loaded" immediately after an image has been loaded

See the code.
index.html
Example: HTML

<!DOCTYPE html>
<html>
<body>
<img src="https://horje.com/avatar.png" onload="loadImage()" width="100" height="132">
<script>
function loadImage() { alert("Image is loaded");
}
</script>
</body>
</html>

Output should be:

How to use onload on an <img> element. Alert "Image is loaded" immediately after an image has been loaded



Single Articles
How to add a JavaScript immediately after a page has been loaded HTML Window Event Attributes
How to use onload on an <img> element. Alert "Image is loaded" immediately after an image has been loaded HTML Window Event Attributes
How to use the onload event to deal with cookies (using "advanced" javascript) HTML Window Event Attributes


Related Articles
HTML onafterprint Event Attribute HTML Window Event Attributes
HTML onbeforeprint Event Attribute HTML Window Event Attributes
HTML onbeforeunload Event Attribute HTML Window Event Attributes
HTML onerror Event Attribute HTML Window Event Attributes
HTML onhashchange Event Attribute HTML Window Event Attributes
HTML onload Event Attribute HTML Window Event Attributes
HTML onoffline Event Attribute HTML Window Event Attributes
HTML ononline Event Attribute HTML Window Event Attributes
HTML onpageshow Event Attribute HTML Window Event Attributes
HTML onresize Event Attribute HTML Window Event Attributes
HTML onunload Event Attribute HTML Window Event Attributes

Type :
html
Category :
Web Tutorial
Sub Category :
HTML Window Event Attributes
Uploaded by :
Admin