判断iframe加载完成

时间:2023-01-26 23:24:15

一、js判断

       var parFrame = document.getElementById("oIframe");
if(parFrame.attachEvent){
parFrame.attachEvent('onload',function(){
console.log('ie');//IE,不包含edge
})
}else{
parFrame.onload = function(){
console.log("iframe加载完成");
}
}

二、jquery判断

       $("#oIframe").load(function(){
console.log("iframe加载完成");
});

父页面:

<div id="parent">
<iframe name="oIframe" id="oIframe" src="iframe.html" frameborder="0" width="1000" height="562"></iframe>
</div>

参考链接:http://blog.csdn.net/qiqingjin/article/details/50487013