【问题标题】:Firefox: Resize iframe according to actual contentFirefox:根据实际内容调整 iframe 的大小
【发布时间】:2012-09-09 08:51:53
【问题描述】:

我有一个 iframe,我正在尝试根据其实际内容调整它的大小(就像我没有任何滚动一样)。我尝试了以下方法:

alert(document.getElementById(iframe).contentWindow.document.body.height); 警报(document.getElementById(iframe).contentWindow.document.body.scrollHeight); alert(document.getElementById(iframe).contentWindow.document.body.offsetHeight);

这些都不起作用。 iframe 包含 iframe 的 id。最后两行在 Chrome 中有效。

任何帮助将不胜感激。

【问题讨论】:

标签: javascript firefox iframe


【解决方案1】:

我认为您无法从外部文档访问 iframe 中文档的属性,但您可以通过其他方式进行操作:从该文档本身访问 iframe 中文档的属性,然后调用函数在外部文件中。然后,这个外部函数将进行大小调整,如下所述:Resize iframe height according to content height in it

【讨论】:

    猜你喜欢
    • 2010-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-15
    • 1970-01-01
    • 1970-01-01
    • 2014-04-29
    相关资源
    最近更新 更多