[javascript] 判断 iframe 是否加载完成
from http://www.planabc.net/2009/09/22/iframe_onload/
1 var iframe = document.createElement("iframe"); 2 iframe.src = "http://www.planabc.net"; 3 4 if (iframe.attachEvent){ // for ie 5 iframe.attachEvent("onload", function(){ 6 alert("Local iframe is now loaded."); 7 }); 8 } else { 9 iframe.onload = function(){ 10 alert("Local iframe is now loaded."); 11 }; 12 } 13 14 document.body.appendChild(iframe);
IE 支持 iframe 的 onload 事件,不过是隐形的,需要通过 attachEvent 来注册。
think in coding