How to use HTML DOM Image onload in JavaScript

In this article I am going to explain about a image onload event in JavaScript.
  • 1988

HTML DOM  image onload event

The HTMl  dom image onload event occur immediately after a image is loaded.

Syntax of image onload event

onload="Code of JavaScript"


Browser support

The image onload event is supported in all major browser.

Example of image  onload event

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript">

    function loadImage() {

        alert("Image is loaded");

    }

</script>

</head>

 

<body>

<img src="gen.jpg" onload="loadImage()" width="100" height="120" />

</body>

</html>

Output:

image onload new meth.jpg

You may also want to read these related articles :here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.