javascript - 如何使用 jQuery 引用 <iframe> 的文档来获取其高度 ()?

标签 javascript jquery iframe document

我正在尝试获取 <iframe>d 文档的高度。我的第一直觉是:

$('iframe').document.height();

$('iframe').contentWindow.document.height();

那些都不管用,而且我的搜索运气也不佳。如果有任何帮助,我将不胜感激!

最佳答案

$("iframe",top.document).contents().height();
alert("iframe height=" + $("iframe",top.document).height());

关于javascript - 如何使用 jQuery 引用 &lt;iframe&gt; 的文档来获取其高度 ()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1562255/

相关文章:

javascript - GWT 阻止来源为 "http://localhost"的框架访问跨来源框架

php - 刷新时 JavaScript 不加载

javascript - jQuery 如果元素存在不起作用

javascript - 书中 "Functional Pattern"的解释 "JavaScript: The Good parts"

javascript - 同步 2 个选择框

jQuery $.when() 其中一个参数来自异步 "Deferred pipe"

html - YouTube HTML5 API - 在轮询播放器当前时间时是否可以获得更好的时间分辨率?

javascript - 动态设置 iframe 高度

javascript - 我可以让这个 React 组件成为无状态的吗?

javascript - 首次登录时需要提醒