js让iframe高度自动

HTML:

<iframe  id="yb_if"   width="940px"   src="连接" frameborder=0 allowfullscreen></iframe>

JS:

//自动同步iframe高度

function reinitIframe(){
    var iframe = document.getElementById("yb_if");
    try{
    iframe.height =  iframe.contentWindow.document.documentElement.scrollHeight;
    }catch (ex){
    }
}
window.setInterval("reinitIframe()", 200);
原文地址:https://www.cnblogs.com/phpyangbo/p/js-iframe-height-auto.html