jquery - 为什么我的获取 iframe 内容高度的 jQuery 方法不能在 Firefox 中运行?

标签 jquery html css firefox iframe

我有以下代码在内容加载后根据内容高度调整 iframe 的大小:

$(frameID).load(function() {
    $(this).height( $(this).contents().find("body").height());
});

这在除 firefox 之外的所有浏览器中都很好用。在 Firefox 中,高度被设置为 0。有谁知道为什么这不起作用?

最佳答案

在 moz 中有同样的问题,使用 DOM ready 方法对我有用一段时间!!

$(document).ready(function(){
  $(frameID).load(function() {
    $(this).height( $(this).contents().find("body").height());
  });
});

关于jquery - 为什么我的获取 iframe 内容高度的 jQuery 方法不能在 Firefox 中运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20698114/

相关文章:

javascript - 为什么我们需要 javascript : while making inline javascript calls

javascript - 如何替换 DOM 节点并将其包装起来?

javascript - jQuery:价格不会更新 - 它不会正确减去(使用 switch 语句)

javascript - 捕捉使用 javascript(或 jquery)点击的超链接?

html - 允许 flex 元素保持固定宽度并在容器内水平滚动

html - Bootstrap 网格框架不适用于表单控件

html - 在同一页面上以不同方式设置两个 html 表单文本区域/输入的样式

javascript - 如何在django中刷新图表而不刷新整个页面

html - 当容器对于表格来说太小时触发滚动条

html - CSS - 视差图像不工作