Frame / IFrame onload event
Definition and Usage
onload event is triggered after a frame or iframe has finished loading.
grammar
onload="JavaScriptCode"
参数 | 描述 |
---|---|
JavaScriptCode | 必须。在事件触发后执行的Javascript代码。 |
Browser Support
All major browsers support onload event
Examples
Example 1
After the frame has loaded pop-up immediately "Frame is loaded":
<html>
<head>
<script>
function load()
{
alert("Frame is loaded");
}
</script>
</head>
<frameset cols="50%,50%">
<frame src="frame_a.htm" onload="load()">
<frame src="frame_b.htm">
</frameset>
</html>
<head>
<script>
function load()
{
alert("Frame is loaded");
}
</script>
</head>
<frameset cols="50%,50%">
<frame src="frame_a.htm" onload="load()">
<frame src="frame_b.htm">
</frameset>
</html>
try it"
Example 2
After the iframe has loaded pop up immediately "Iframe is loaded":
<html>
<head>
<script>
function load()
{
alert("Iframe is loaded");
}
</script>
</head>
<iframe onload="load()" src="http://w3cschool.cc">
<p>Your browser does not support iframes.</p>
</iframe>
</html>
<head>
<script>
function load()
{
alert("Iframe is loaded");
}
</script>
</head>
<iframe onload="load()" src="http://w3cschool.cc">
<p>Your browser does not support iframes.</p>
</iframe>
</html>
try it"
Frame / IFrame objects