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();
        });

猜你喜欢

转载自www.cnblogs.com/cheua/p/9482046.html