【发布时间】:2017-05-19 09:59:24
【问题描述】:
我正在处理一个包含 iframe 的页面,我在 Firefox 中遇到了一个主要问题。 我使用这个 javascript 来调整 iframe 大小:
<script language="JavaScript"> function autoResize(id){
var newheight;
var newwidth;
if(document.getElementById){
newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;
}
document.getElementById(id).height= (newheight) + "px";
document.getElementById(id).width= (newwidth) + "px"; }
<iframe src="https://like-coppers.de/kundenbereich/" scrolling="no" border="none" width="100%" height="100%" name="CHANGETHIS" id="CHANGETHIS" marginheight="0" frameborder="0" onload="autoResize('CHANGETHIS');" onresize="autoResize('CHANGETHIS');"></iframe>
在 chrome 上完美运行(忽略边框): 但在 Firefox 上它被切断了:
你知道解决办法吗?
【问题讨论】:
-
在 Firefox 中,您需要查询
documentElement.scrollHeight而不是body.scrollHeight -
@CBroe 完美运行!!!非常感谢。
-
你能把它作为答案提交给我吗?
标签: javascript css firefox iframe