代码改变世界

iframe 自适应高度

2010-11-11 16:35  hailibu  阅读(205)  评论(0编辑  收藏  举报

    <script type="text/javascript">
        function iframeFitHeight() {
            var iframe = document.getElementById("loaderFrame");
            try {
                iframe.height = iframe.contentWindow.document.documentElement.scrollHeight + 100; 
             }
             catch (ex) { }
        }
        window.setInterval("iframeFitHeight()", 200);
    </script>