Image onload event
Definition and Usage
onload event immediately after the image is loaded.
grammar
onload= "JavaScriptCode"
参数 | 描述 |
---|---|
JavaScriptCode | 必须。在事件触发后执行的Javascript代码。 |
Browser Support
All major browsers support onload event
Examples
Examples
After the image has loaded pop-up "image is loaded":
<html>
<head>
<script>
function loadImage()
{
alert("图片加载完成");
}
</script>
</head>
<body>
<img src="w3javascript.gif" onload="loadImage()">
</body>
</html>
<head>
<script>
function loadImage()
{
alert("图片加载完成");
}
</script>
</head>
<body>
<img src="w3javascript.gif" onload="loadImage()">
</body>
</html>
try it"
Image Object