给出几个链接 控制iframe加载的内容不同大小也不同,如何根据加载的不同来控制iframe的高度呢

解决方案 »

  1.   

    <iframe id="frame_content1" src="new_neiye/new_zhongzujieshao.htm" width="1002" scrolling="no" frameborder="0" allowtransparency="ture" onload="this.height = '100px';"></iframe>
                        
                        <script type="text/javascript">
    function reinitIframe(){
    var iframe = document.getElementById("frame_content1");
    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>
      

  2.   

    在加载页面,设置iframe的高度就可以了。
      

  3.   

    document.getElementById("iframeId").height = Math.max(document.getElementById("iframeId").contentWindow.document.body.scrollHeight,document.getElementById("iframeId").contentWindow.document.documentElement.scrollHeight).
      

  4.   

    楼上的说的控制我都懂,但是我的要求是内部页面出现变化的时候,iframe大小也随之发生变化,如何才能有效的控制呢,意思也就是说iframe高度随着内部加载页面内容高度变化而变化,相当于内部的加载页面来处理主窗体的这个iframe
      

  5.   

    举个例子 加载数据的话 有两页,第一页就是标准大小,当下一页的时候(在内嵌的页面的处理),第二页的数据少 页面也小了 这时候如何让iframe的大小也随之变化呢
      

  6.   

    iframe比较麻烦吧
    用div可以的