var iframe = document.createElement("iframe"); iframe.style.width = "265px"; iframe.style.height = "490px"; iframe.style.border = "none"; iframe.src = "http://cnblogs.com/walls"; if(iframe.attachEvent){ //IE iframe.attachEvent("onload", function(){ alert("loaded 1"); }); }else{ iframe.onload = function(){ console.log("loaded 2"); }; }
- IE 支持 iframe 的 onload 事件,不过是隐形的,需要通过 attachEvent 来注册。
摘自怪飞博客:http://www.planabc.net/2009/09/22/iframe_onload/