得到的高度只有一小部分。<iframe name="ifrName" src="http://www.qq.com" scrolling="no" width="100%" height="100%" frameborder="0"></iframe> 
这是代码

解决方案 »

  1.   

    这个问题,CSDN上其实很多人都问过,你可以找找历史帖子,一个一个参看过去!关键字iframe自适应或者iframe高度!
      

  2.   

    就是把iframe的height值设置成它里面文档的height值就可以。window.onload = (function () { 
    var iObj = document.getElementById(‘iId‘); 
    iObj.height = iObj.contentWindow.document.documentElement.scrollHeight; 
    });
      

  3.   

    跨域不能访问iframe里面的对象所以办法就是硬性给iframe一个高度 同时设置 scroll可见
      

  4.   


    <!-- IFRAME自动高度代码 -->
    <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 : 0function 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自动高度代码 end -->以下是调用:<iframe id="myTestFrameID" onload="js:{dyniframesize('myTestFrameID');}" marginwidth=0 marginheight=0 frameborder=0 name=ilovell scrolling=no src="guest/index.asp" width=550 height=100></iframe>
      

  5.   

    我用的是jQuery,要引用jQuery库
    子页面代码: 
    <script type="text/javascript" >
            $(window.parent.document).find("#main").load(function() {
                var main = $(window.parent.document).find("#main");
                var thisheight = $(document).height();
                main.height(thisheight);
            });
        </script>
    Iframe所在页面代码 :#main是Iframe的ID
    $("#main").load(function() {
                var mainheight = $(this).contents().find("body").height();
                $(this).height(mainheight);
            });