为啥我的获取 iframe 内容高度的 jQuery 方法在 Firefox 中不起作用?
Posted
技术标签:
【中文标题】为啥我的获取 iframe 内容高度的 jQuery 方法在 Firefox 中不起作用?【英文标题】:Why isn't my jQuery method for getting iframe content height working in firefox?为什么我的获取 iframe 内容高度的 jQuery 方法在 Firefox 中不起作用? 【发布时间】:2014-01-08 23:46:29 【问题描述】:我有以下代码在内容加载后根据它的内容高度调整 iframe 的大小:
$(frameID).load(function()
$(this).height( $(this).contents().find("body").height());
);
这适用于除 Firefox 之外的所有浏览器。在 Firefox 中,高度只是设置为 0。有谁知道为什么这不起作用?
【问题讨论】:
【参考方案1】:在 moz 中遇到了同样的问题,使用 DOM 就绪方法对我有用!
$(document).ready(function()
$(frameID).load(function()
$(this).height( $(this).contents().find("body").height());
);
);
【讨论】:
以上是关于为啥我的获取 iframe 内容高度的 jQuery 方法在 Firefox 中不起作用?的主要内容,如果未能解决你的问题,请参考以下文章