iframe自动适应高度

父页面:

 function reinitIframe() {
            var iframe = document.getElementById("frame_content");

            try {
                var bHeight = iframe.contentDocument.body.scrollHeight;
                var dHeight = iframe.contentDocument.documentElement.scrollHeight;
                var height = Math.max(bHeight, dHeight);
                iframe.height = height;
            } catch (ex) { }
        }

 

子页面:

  $().ready(function () {

            window.parent.reinitIframe();
        });

 

posted @ 2018-08-15 16:08  Chanwah  阅读(182)  评论(0编辑  收藏  举报