比普通自适应还麻烦一些,是IFRAME调的页面有展开收缩的功能,展开可以把IFRAME撑开,但是收缩后,IFRMAE高度不会跟着收缩,下边就空出一块了,哪位高手帮帮忙,拜谢

解决方案 »

  1.   

    就你的分 我是不想把我收藏的代码发出来的 哎还是发了吧<iframe id="frame_content" src="1.html" scrolling="no" frameborder="0"  > </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>
      

  2.   

    谢谢,你珍藏的代码,就是我现在用得,我也奇怪,为什么不行,调用页面里的层关闭后,IFRAME不能随着收缩
      

  3.   

    我自己解决了,这个好使:)
    <script language="javascript"> 
    function resize(){var h=50;
    try{
    if(ifr_lb&&ifr_lb.document&&ifr_lb.document.body){
    var o=ifr_lb.document.body;
    var h=o.scrollHeight + (typeof(o.clientTop)== 'number' ?o.clientTop * 2 : 0);}
    }
    catch(e){var h=50;window.status=e.description;}
    if(h<50){h=50;}
    document.getElementById('ifr_lb').style.height=h+'px';
    return h+"px";
    }
    window.onresize=resize;
    </script><iframe id="ifr_lb" name="ifr_lb" onload="resize()" frameborder="0" src="http://www.huichi.cn/" scrolling="no" frameborder="no" style="width:100%;;height:expression(resize())" height="22" target="_tc">