http://expert.csdn.net/Expert/topic/2381/2381759.xml?temp=.6651728

解决方案 »

  1.   

    在你的iframe页面onload的时候修改他的高度为他document.body.scrollHeight就可以

    代码:在你的iframe的页面里加
    -----------------------------
    function changeIframeHeight()  //自动改变 Iframe 的高度
    {
       if(top != self)
       {
          window.parent.document.getElementById(self.name).height =
    document.body.scrollHeight;
       }
    }
    function window.onload()
    {
       changeIframeHeight(); //改变 Iframe 高
    }
      

  2.   

    index.html
    <body onload="init()">
    <iframe scrolling=no id=i1 src='test6.html'>
    </iframe>
    <script>
    function init()
    {
    document.all.i1.style.height = document.all.i1.contentWindow.document.body.style.height + document.all.i1.contentWindow.document.body.scrollHeight
    document.all.i1.style.width = document.all.i1.contentWindow.document.body.style.width + document.all.i1.contentWindow.document.body.scrollWidth;
    }
    </script>
    </body>test6.html
    <body >
    fsd<br>
    <br><br><br>
    <br><br>
    dfsfsfdsfsdf<br>
    <br>
    <br>
    <br>
    <br><br>
    dfs<br><br>
    <br><br><br><br>
    <br>
    <br>sdf
    </body>
      

  3.   

    謝謝各位了,我的問題已經解決了,還請教一個新問題,就是怎麼在一個彈出窗口中(window.open)在父窗口(opener)里的iframe里插入一段HTML代碼,謝謝!解決後立即結貼!
      

  4.   

    opener.iframeName.doucment.write("<div style='color:#ff0000'>xxxxxxxxx</div>")
      

  5.   

    to: xinyunyishui(心云意水) 在我的iframe裡面已經有許多HTML代碼了,我想在iframe的光標位置插入一段HTML代碼,謝謝!
      

  6.   

    window.opener.frame[1].innerHTML =
      

  7.   

    不好意思window.opener.frame[1].document.write(<p>你好</p>)
      

  8.   

    <iframe name=demo></iframe>
    <script language="JavaScript">
    <!--
    demo.document.designMode="on"
    //-->
    </script>
    <input type="submit" onclick="demo.focus();demo.document.selection.createRange().pasteHTML('fason')">
      

  9.   

    demo.document.body.innerHTML+="HTML代码";
      

  10.   

    <iframe onload="this.height=this.document.body.scrollHeigth">