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

求助 js判断iframe是否加载完成
我现在在做一个多站点同步登陆功能,部分代码如下:
<iframe src="http://a.com/setCookie.html"></iframe>
<iframe src="http://b.com/setCookie.html"></iframe>
<iframe src="http://c.com/setCookie.html"></iframe>
<iframe src="http://d.com/setCookie.html"></iframe>
<script>
document.location.href={$redirect}
</script>
在setCookie.html里面有设置cookie的js程序

现在的问题是:我该怎样写js才能使下面的页面跳转代码在上面四个框架全部加载完之后才执行跳转?
上面四个框架加载完是指里面的JS已经执行完毕。

求高手指点。在线等。。。
js iframe

------解决方案--------------------
<iframe id="ifrm"></iframe>
document.ifrm.document.readyState == "complete"
------解决方案--------------------
<iframe name="ifr"></iframe>
....
<iframe name="ifr"></iframe>

var ifrs=document.getElementsByName("ifr"),L=ifrs.length,n=0;
for(var i=0;i<L;i++ ){
   ifrs.onload=function(){
      n++;
      if(n==L) alert('ok');
  }
}