iframe高度自适应

function reinitIframe(){
var iframe = document.getElementById("mainFrame");
try{
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
iframe.height = height;
console.log(height);
}catch (ex){}
}

window.setInterval("reinitIframe()", 200);



附地址:http://caibaojian.com/iframe-adjust-content-height.html

你可能感兴趣的:(html,iframe)