javscript 实现iframe加载内容页出现Loading效果

 <iframe src="http://www.baidu.com" frameborder="0" marginheight="0" marginwidth="0"
scrolling
="auto" width="100%" height="100px" id="alarmframe" onreadystatechange="stateChangeIE(this)"
style
="display: none" onload="stateChangeFirefox(this)">iframe>
<div id="LoadDiv" align="center">
<img src="http://www.cnblogs.com/Repository/Image/Loading.gif" />
div>
<script type="text/javascript">
function stateChangeIE(_frame) {
if (_frame.readyState == "complete")//state: loading, interactive, complete
{
var loader = document.getElementById("LoadDiv");
//loader.innerHTML = "加载中";
loader.style.display = "none";
_frame.style.visibility
= "visible";
_frame.style.display
= "block"
}
}
function stateChangeFirefox(_frame) {
var loader = document.getElementById("LoadDiv");
//loader.innerHTML = "加载中";
loader.style.display = "none";
_frame.style.visibility
= "visible";
_frame.style.display
= "block"
}
// alarmframe.location.href = "http://www.baidu.com";
script>

  

转载于:https://www.cnblogs.com/yannis/archive/2011/08/16/2140169.html

你可能感兴趣的:(javscript 实现iframe加载内容页出现Loading效果)