iframe放在table里 table自动高度 iframe hight=100%

解决方案 »

  1.   

    是不是自动获得src页面的高度和宽度,然后iframe自动调整大小?
      

  2.   

    <iframe name=tag align=center width=169 frameborder=0 scrolling=no src="frame_test.html" onload="this.height=tag.document.body.scrollHeight"></iframe>
      

  3.   

    楼上的说的对===================================================================
    中国DotNet程序员俱乐部 -- www.willsft.com -- 中国最专业的DotNet技术社区!技术支持群:3354034、34857327 、24694039、
    19055417、35202852、2684939、1621937、35112134 
    ===================================================================
      

  4.   

    see:
    http://blog.csdn.net/meizz/archive/2006/03/27/639857.aspx
      

  5.   

    <iframe name=tag align=center width=169 frameborder=0 scrolling=no src="frame_test.html" onload="this.height=tag.document.body.scrollHeight"></iframe>
    这个方法可以!
      

  6.   

    楼上的代码我看过!
    我再贴出来!<html>  
        <head>  
           <meta  http-equiv='Content-Type'  content='text/html;  charset=gb2312' />  
           <meta  name='author'  content='F.R.Huang(meizz梅花雪)//www.meizz.com' />  
           <title>iframe自适应加载的页面高度</title>  
        </head>  
         
        <body>
            <div><iframe src="child.htm"></iframe></div>
        </body>
    </html>child.htm:<html>  
    <head>  
        <meta  http-equiv='Content-Type'  content='text/html;  charset=gb2312' />  
        <meta  name='author'  content='F.R.Huang(meizz梅花雪)//www.meizz.com' />  
        <title>iframe  自适应其加载的网页(多浏览器兼容)</title>  
        <script type="text/javascript">
        <!--
        function iframeAutoFit()
        {
            try
            {
                if(window!=parent)
                {
                    var a = parent.document.getElementsByTagName("IFRAME");
                    for(var i=0; i<a.length; i++) //author:meizz
                    {
                        if(a[i].contentWindow==window)
                        {
                            var h1=0, h2=0;
                            a[i].parentNode.style.height = a[i].offsetHeight +"px";
                            a[i].style.height = "10px";
                            if(document.documentElement&&document.documentElement.scrollHeight)
                            {
                                h1=document.documentElement.scrollHeight;
                            }
                            if(document.body) h2=document.body.scrollHeight;                        var h=Math.max(h1, h2);
                            if(document.all) {h += 4;}
                            if(window.opera) {h += 1;}
                            a[i].style.height = a[i].parentNode.style.height = h +"px";
                        }
                    }
                }
            }
            catch (ex){}
        }
        if(window.attachEvent)
        {
            window.attachEvent("onload",  iframeAutoFit);
            //window.attachEvent("onresize",  iframeAutoFit);
        }
        else if(window.addEventListener)
        {
            window.addEventListener('load',  iframeAutoFit,  false);
            //window.addEventListener('resize',  iframeAutoFit,  false);
        }
        //-->
        </script>  
    </head>  
    <body>
        <table border="1" width="200" style="height: 400px; background-color: yellow">
            <tr>
                <td>iframe  自适应其加载的网页(多浏览器兼容,支持XHTML)</td>
            </tr>
        </table>
    </body>  
    </html>