日期:2014-05-16  浏览次数:20499 次

监视iframe的onload事件
我在一个页面中有一个iframe,其ID为I1,请问我如何在父窗口中监视iframe的onload事件,即:当我用脚本改变I1的location.href属性,页面重新载入后怎样才能又一次触发父窗口onload脚本。
谢谢

------解决方案--------------------
<iframe src= " " id= "T1 "> </iframe>
<script type= "text/javascript ">
var c = document.getElementById( "T1 ");
c.onreadystatechange = function(){
alert(this.readyState);
}
</script>
<input type= "button " value= "sohu " onclick= "c.src= 'http://www.sohu.com ' "/>
<input type= "button " value= "163 " onclick= "c.src= 'http://www.163.com ' "/>
------解决方案--------------------
支持楼上!:)
------解决方案--------------------
在iframe标签里加个onload
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=GBK ">
<title> iframe </title>
<script type= "text/javascript ">
function loadWin(){alert( "AAA ");}
window.onload=loadWin;
</script>
</head>
<body style= "margin:0 0 0 0; ">
<iframe src= " " id= "f1 " style= "margin:0 0 0 0; " onload= "loadWin() "> </iframe>
</body>
</html>

------解决方案--------------------
支持楼上!:)

IFRAME有onload事件