<table style="width:100%; height:500px;">
        <tr>
            <td>
                <iframe src="/Home.html" height="100%" id="iframe" name="iframe" width="100%"
                    frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
            </td>
        </tr>
    </table>
这个是可以的,因为设置了table 的高度,但是这样就不行了
<table style="width:100%; height:100%;">
        <tr>
            <td>
                <iframe src="/Home.html" height="100%" id="iframe" name="iframe" width="100%"
                    frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
            </td>
        </tr>
    </table>
因为有的情况下 iframe的 src 的页面是不确定高度的,所以请教怎么解决?

解决方案 »

  1.   

    http://www.360doc.com/content/11/0203/22/19147_90600138.shtml
      

  2.   

    function SetCwinHeight() {
                var iframeid = document.getElementById("iframe"); //iframe id
                if (document.getElementById) {
                    if (iframeid && !window.opera) {
                        if (iframeid.contentDocument && iframeid.contentDocument.body.offsetHeight) {
                            iframeid.height = iframeid.contentDocument.body.offsetHeight;
                        } else if (iframeid.Document && iframeid.Document.body.scrollHeight) {
                            iframeid.height = iframeid.Document.body.scrollHeight;
                        }
                    }
                }
            } 
    设置了 ,但是页面的内容还是没有显示完整
      

  3.   

    function reinitIframe(id) {
                var iframe = $("#" + id);
                var h = $(window).height() - iframe.offset().top - 21;
                iframe.height(h);
            }
    这样就完成了,非常的简单