Image onloadEvent
Image Object
Definition and Usage
The onload event executes immediately after the image has finished loading.
Syntax
onload="JavaScriptCode"
| Parameter | Description |
|---|---|
| JavaScriptCode | Required. The JavaScript code to execute after the event is triggered. |
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the onload event
Example
Example
After the image has finished loading, pop up "Image loaded":
<html>
<head>
<script>
function loadImage()
{
alert("Image loaded");
}
</script>
</head>
<body>
<img src="w3javascript.gif.html" onload="loadImage()">
</body>
</html>
<head>
<script>
function loadImage()
{
alert("Image loaded");
}
</script>
</head>
<body>
<img src="w3javascript.gif.html" onload="loadImage()">
</body>
</html>
Try it Yourself »
Image Object Other Extensions