iframe

<iframe name="menuFrame" id="menuFrame" onload="reinitIframe()" style="overflow:visible;"
   	scrolling="no" height="100%" width="100%">
</iframe>
 

javascript

        window.onresize = function () {
            reinitIframe();
        }
        function reinitIframe(){
            var iframe = document.getElementById("menuFrame");
            try{
                var bHeight = iframe.contentWindow.document.body.scrollHeight;
                var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
                var height = Math.min(bHeight, dHeight);
                iframe.height = height+50;
                // console.log(iframe.height);
            }catch (ex){}
        }
        // 定时触发
        window.setInterval("reinitIframe()", 200);
 

相关文章: