主页面:
先<iframe id="frameName" src='aaa.htm'> </iframe>内嵌页:aaa.htm<body onload="parent.document.getElementById('frameName').height=document.body.scrollHeight;">

解决方案 »

  1.   

    呵呵呵呵,内页面不是我控制的,是google和yahoo的搜索结果页面。
    那就没有其它办法了吗?
    谢谢fusoft在我上一个贴子中的回复!
      

  2.   

    每查询出一次结果,加上这句
    document.getElementById('frameName').height=document.getElementById('frameName').scrollHeight;
      

  3.   

    还是不行啊!没有反应。是不是在height调整之后页面才加载的。
      

  4.   

    <script language="Javascript">
    var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
    //extra height in px to add to iframe in FireFox 1.0+ browsers
    var FFextraHeight=getFFVersion>=0.1? 16 : 0 ;function dyniframesize(iframename)
     {
      var pTar = null;
      if (document.getElementById)
      {
        pTar = document.getElementById(iframename);
      }
      else
      {
        eval('pTar = ' + iframename + ';');
      }   
      if (pTar && !window.opera)
      {
        //begin resizing iframe
        pTar.style.display="block";
        
        if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight)
        {
          //ns6 syntax
          pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight; 
        }
        else if (pTar.Document && pTar.Document.body.scrollHeight)
        {
          //ie5+ syntax
          pTar.height = pTar.Document.body.scrollHeight;
        }
      }
     }
      </script><iframe id="contentframe" border="0" name="content" frameSpacing="0" src="aaa.html"
    scrolling="no" onload="javascript:{dyniframesize('contentframe');}" height="100%"
    allowTransparency></iframe>
      

  5.   

    多谢 seaer06
    可惜老是生成页面错误,
    ie6.0显示没有权限,还是调节不了!:( 
      

  6.   

    自己用ASP获取对方页面内容再写入吧!
      

  7.   

    <html>  
        <head>  
           <meta  http-equiv='Content-Type'  content='text/html;  charset=gb2312' />  
           <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' />  
        <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++) 
                    {
                        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>
      

  8.   

    谢谢各位,虽然问题一直没有解决,但可能这是一个不可能实现的要求。
    1.iframe根据调用内容不同自动适应高度
    2.调用的内容是不可控制的,是其他外在网站的网页。不过,无论怎么说,朋友们给的各种方法,都是在其他方面的很好的例子!!