简体   繁体   English

使iframe自动调整高度

[英]Make iframe automatically adjust height

I am unable to adjust auto height according to the page content. 我无法根据页面内容调整自动高度。

Code - 代码-

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

I prefer Make iframe automatically adjust height according to the contents without using scrollbar? 我更喜欢让iframe根据内容自动调整高度而无需使用滚动条? but this code doesn't work. 但是此代码不起作用。 Please suggest me how to get complete data without using scroll? 请建议我如何在不使用滚动条的情况下获取完整数据?

Try this 尝试这个

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM