<div id="dv_iframe" style="display:none;">
<iframe id='modcontent' name='modcontent' frameborder='0' src='test.html'
scrolling='no' ></iframe>
</div>
display爲none的時候,iframe是不能自適應的,需要判斷src是否加載完畢,在執行自適應的函數,
IE 支持 iframe 的 onload 事件,不過是隱形的,需要通過 attachEvent 來註冊
判斷加載情況:
var iframe=document.getElementById("dv_iframe");
if (iframe.attachEvent){
iframe.attachEvent("onload", function(){
//自適應函數調用
});
} else {
iframe.onload = function(){
//自適應函數調用
};
}