本文实例讲述了JS判断iframe是否加载完成的方法。分享给大家供大家参考,具体如下:/p>
"http://www.w3.org/TR/html4/loose.dtd">
var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
var iframe = document.createElement("iframe");
iframe.src = "http://www.jb51.net/";
if (isIE) {
iframe.onreadystatechange = function(){
if(iframe.readyState == "loaded" || iframe.readyState == "complete"){
alert("loaded");
}
};
} else {
iframe.onload = function(){
alert("loaded");
};
}
document.body.appendChild(iframe);
或者/p>
"http://www.w3.org/TR/html4/loose.dtd">
var iframe = document.createElement("iframe");
iframe.src = "http://www.jb51.net/";
if (iframe.attachEvent){
iframe.attachEvent("onload", function(){
alert("loaded");
});
} else {
iframe.onload = function(){
alert("loaded");
};
}
document.body.appendChild(iframe);
希望本文所述对大家JavaScript程序设计有所帮助。
更多JS判断iframe是否加载完成的方法相关文章请关注PHP中文网!
本文原创发布php中文网,转载请注明出处,感谢您的尊重!