Frame/IFrame onloadイベント
Frame/IFrame オブジェクト
定義と使い方
onload イベントは、frameまたはiframeの読み込みが完了したときにトリガーされます。
構文
onload="JavaScriptCode"
| パラメータ | 説明 |
|---|---|
| JavaScriptCode | 必須。イベント発生後に実行するJavaScriptコード。 |
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザが onload イベントをサポートしています。
例
例1
frameの読み込み完了直後に "Frame is loaded" をポップアップ表示します:
<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>
試してみる »
例2
iframeの読み込み完了直後に "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>
試してみる »
Frame/IFrame オブジェクト その他の拡張