转自:http://www.planabc.net/2009/09/22/iframe_onload/
最近, Nicholas C. Zakas 文章《Iframes, onload, and document.domain》的评论中 Christopher 提供了一个新的判断方法(很完美):
最近, Nicholas C. Zakas 文章《Iframes, onload, and document.domain》的评论中 Christopher 提供了一个新的判断方法(很完美):
var iframe = document.createElement("iframe");
iframe.src = "http://www.planabc.net";
if (iframe.attachEvent){
iframe.attachEvent("onload", function(){
alert("Local iframe is now loaded.");
});
} else {
iframe.onload = function(){
alert("Local iframe is now loaded.");
};
}
document.body.appendChild(iframe);
本文介绍了一种通过监听iframe的加载事件来判断其是否成功加载的方法。这种方法适用于跨域场景,并且提供了兼容不同浏览器的实现方案。对于网页开发者来说,这是一种实用的技术细节。
310

被折叠的 条评论
为什么被折叠?



