定义和用法
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="/images/2021/07/13/07/2021071307052115456516.htm" onload="load()">
<frame src="/images/2021/07/13/07/2021071307052115458487.htm">
</frameset>
</html>
<head>
<script>
function load()
{
alert("Frame is loaded");
}
</script>
</head>
<frameset cols="50%,50%">
<frame src="/images/2021/07/13/07/2021071307052115456516.htm" onload="load()">
<frame src="/images/2021/07/13/07/2021071307052115458487.htm">
</frameset>
</html>
知识兔 »
实例 2
在iframe载入完成后立即弹出 "Iframe is loaded" :
<html>
<head>
<script>
function load()
{
alert("Iframe is loaded");
}
</script>
</head>
<iframe onload="load()" src="/images/2021/07/13/07/2021071307052213865898.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="/images/2021/07/13/07/2021071307052213865898.cc">
<p>Your browser does not support iframes.</p>
</iframe>
</html>
知识兔 »
Frame/IFrame 对象