Frame/IFrame onloadEvent
Frame/IFrame Object
Definition and Usage
The onload event is triggered when a frame or iframe 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
Examples
Example 1
Pop up "Frame is loaded" immediately after the frame has finished loading:
<html>
<head>
<script>
function load()
{
alert("Frame is loaded");
}
</script>
</head>
<frameset cols="50%,50%">
<frame src="frame_a.htm.html" onload="load()">
<frame src="frame_b.htm.html">
</frameset>
</html>
<head>
<script>
function load()
{
alert("Frame is loaded");
}
</script>
</head>
<frameset cols="50%,50%">
<frame src="frame_a.htm.html" onload="load()">
<frame src="frame_b.htm.html">
</frameset>
</html>
Try it Yourself »
Example 2
Pop up "Iframe is loaded" immediately after the iframe has finished loading:
<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 Yourself »
Frame/IFrame Object Other Extensions