我有以下代码在内容加载后根据内容高度调整 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/