javascript Iframe自适应高度

/*Iframe自适应高度*/
function changeFrameHeight() {
    var ifm = document.getElementById("ifm");
    var subWeb = document.frames ? document.frames["ifm"].document : ifm.contentDocument;
    if (ifm != null && subWeb != null) {
        ifm.height = subWeb.body.scrollHeight;
        ifm.width = subWeb.body.scrollWidth;
    } 
}
<iframe id="ifm" name="ifm" frameborder="0" style=" min-height:400px;" scrolling="no" marginheight="0" marginwidth="0" onload="changeFrameHeight()">
</iframe>

 

posted @ 2016-10-28 11:57  xd_1989  阅读(194)  评论(0)    收藏  举报