【发布时间】: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