iframe自适应高度

JS-CODE
 
<iframe id="frame_content" src="iframe_b.html" scrolling="no" frameborder="0" onload="this.height=100"></iframe>
    <script type="text/javascript">
    function reinitIframe(){
    var iframe = document.getElementById("frame_content");
    try{
    var bHeight = iframe.contentWindow.document.body.scrollHeight;
    var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
    var height = Math.max(bHeight, dHeight);
    iframe.height =  height;
    }catch (ex){}
    }
    window.setInterval("reinitIframe()", 200);
    </script>
本文转载自http://www.cnblogs.com/MaxIE/archive/2008/08/13/1266597.html
posted on 2009-08-28 21:37  ToKens  阅读(180)  评论(0编辑  收藏  举报