Javascript 使iframe自动调整高度

Javascript 使iframe自动调整高度,javascript,jquery,html,css,iframe,Javascript,Jquery,Html,Css,Iframe,我无法根据页面内容调整自动高度 代码- <iframe width="100%" id="myFrame" src="http://www.learnphp.in" scrolling="no"> </iframe> 我更喜欢,但是这个代码不起作用。请建议我如何不使用scroll获取完整数据?试试这个 <script> function autoResize(myiframe){ var newheight; var newwidt

我无法根据页面内容调整自动高度

代码-

<iframe width="100%" id="myFrame" src="http://www.learnphp.in" scrolling="no">
</iframe>

我更喜欢,但是这个代码不起作用。请建议我如何不使用scroll获取完整数据?

试试这个

<script>   
function autoResize(myiframe){
    var newheight;
    var newwidth;

    if(document.getElementById){
        newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
        newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;
    }

    document.getElementById(myiframe).height= (newheight) + "px";
    document.getElementById(myiframe).width= (newwidth) + "px";
}
</script>

<body>  
 <div align="center" style="padding-left:50px">
      <iframe id="myiframe" src="helpdesk/index.php" width="800"></iframe>
 </div>
</body>

函数自动调整大小(myiframe){
var newheight;
新宽度;
if(document.getElementById){
newheight=document.getElementById(id).contentWindow.document.body.scrollHeight;
newwidth=document.getElementById(id).contentWindow.document.body.scrollWidth;
}
document.getElementById(myiframe).height=(newheight)+“px”;
document.getElementById(myiframe).width=(newwidth)+“px”;
}

不工作。在Body中找不到函数autoResize()。请参阅此。类似的一个@chandu是的,它在同一个域中工作。它将如何跨域工作?