【问题标题】:Increasing iframe height增加 iframe 高度
【发布时间】:2010-12-24 19:25:22
【问题描述】:

我正在使用 jquery load() 将“html”页面加载到 div(例如:#targets)中。div 位于 iframe 下。加载html文件后,div高度和iframe高度没有根据html文件内容高度增加。

如何根据 div 中的 htm 内容改变 iframe 和 div 的高度。

【问题讨论】:

  • 对给出的答案有任何反馈吗?没有一个适合你???

标签: jquery iframe load


【解决方案1】:

我建议阅读这篇博文

jQuery iFrame Sizing

// For some browsers (for opera, safari check blog post, chrome?)
$('iframe').load(function() {
    this.style.height =
    this.contentWindow.document.body.offsetHeight + 'px';
});

【讨论】:

    【解决方案2】:

    试试这个css代码:

    div, iframe
    {
      overflow:auto;
      height:auto;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-07
      • 2013-02-01
      • 2019-02-09
      • 2018-05-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多