【问题标题】:Resize iFrame height according to content根据内容调整 iFrame 高度
【发布时间】:2012-08-03 07:51:58
【问题描述】:

我有一个弹出页面,其中有一个 iframe,它反过来加载另一个页面。

我想根据加载的页面大小调整 iframe 高度。

【问题讨论】:

  • 我很抱歉freefaller,这里的新手。我添加了 aspx 标记,不知道在哪里丢失了。再次编辑问题。

标签: asp.net html iframe


【解决方案1】:

一种简单的方法是使用 javascript:

<script language="JavaScript">
  function autoResize(id){
  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(id).height= (newheight) + "px";
  document.getElementById(id).width= (newwidth) + "px";
}
</script>

<IFRAME SRC="Iframef/iframep.aspx" width="100%" height="200px" id="iframe1" marginheight="0" frameborder="0" onLoad="autoResize('iframe1');"></iframe>

【讨论】:

    猜你喜欢
    • 2010-12-18
    • 1970-01-01
    • 2012-05-21
    • 1970-01-01
    • 2012-07-29
    • 1970-01-01
    • 1970-01-01
    • 2014-11-06
    • 1970-01-01
    相关资源
    最近更新 更多