iframe加载loading...

<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<body>
<div id="load" align="center">
<img src="http://sc.cnwebshow.com/upimg/allimg/070707/01294420.gif" />&nbsp;loading...
</div> <!-- 首先放一个div,用做loading效果 -->
<iframe id="demo" src="http://www.baidu.com" width="100%" height="100%" frameborder="0" scrolling="no" marginheight="0"></iframe> <!-- src 里面放你想要的网页-->
<script type="text/javascript">
//<![CDATA[
var a = document.getElementById("demo");
var b = document.getElementById("load");
a.style.display = "none"; //隐藏
b.style.display = "block"; //显示
a.onreadystatechange = function() {
if (this.readyState=="complete") { //最近才知道的。不然也写不出来。
// 解释:一个iframe加载完毕的状态是complete,
// 就象xmlhttp里的那个==4一样,这些都是规定的...
b.innerHTML = "load complete!";
b.style.display = "none";
a.style.display = "block";
}
}
//]]>

</script>
</body>

看了人家的代码:
var state = this.readyState;
if (state == "loaded" || state == "interactive" || state == "complete") {
this.onreadystatechange = null;
b.innerHTML = "load complete!";
b.style.display = "none";
a.style.display = "block";
}
else
{
window.setTimeout( "回调函数" , 100);
}
好象比我的要更加严密。
但我有点不懂。我的函数是这么写的 a.onreadystatechange = function() {}
那么我这个回调函数该怎么写。
看人家的代码:
function on(){
if ( window.onload )
{
alert( "page onload." );
}
else{
window.setTimeout( on, 1000);
}
}
on();
为什么最后还有个on()啊;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值