【问题标题】:Make iframe automatically adjust height让 iframe 自动调整高度
【发布时间】:2013-10-28 05:04:18
【问题描述】:

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

代码 -

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

我更喜欢Make iframe automatically adjust height according to the contents without using scrollbar?,但这段代码不起作用。请建议我如何在不使用滚动的情况下获取完整数据?

【问题讨论】:

标签: javascript jquery html css iframe


【解决方案1】:

试试这个

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

【讨论】:

  • 不工作。无法在正文中找到函数 autoResize()
猜你喜欢
  • 2011-08-23
  • 1970-01-01
  • 1970-01-01
  • 2014-04-25
  • 2020-04-13
  • 2012-08-19
  • 1970-01-01
  • 2016-06-13
  • 2018-03-23
相关资源
最近更新 更多