【发布时间】:2011-06-06 21:21:50
【问题描述】:
Safari iphone/ipad 不支持 iframe 上的宽度和高度为 0px,而是放一个大的。
除了将 display 设置为 none 之外,有没有人看到或找到解决方法,因为 0px 似乎适用于所有浏览器。
【问题讨论】:
标签: javascript html
Safari iphone/ipad 不支持 iframe 上的宽度和高度为 0px,而是放一个大的。
除了将 display 设置为 none 之外,有没有人看到或找到解决方法,因为 0px 似乎适用于所有浏览器。
【问题讨论】:
标签: javascript html
我通过清零我能找到的每个参数来解决这个问题:
var el = document.createElement("iframe");
el.setAttribute('id', 'yourFrameId');
el.height = 0;el.width = 0;
el.hspace="0";el.vspace="0";
el.marginheight="0";el.marginwidth="0";
el.frameBorder = "0";el.scrolling = "No";
或内联:
<iframe src="test.html" id="yourFrameId" width="0" marginwidth="0" height="0" marginheight="0" align="top" scrolling="No" frameborder="0" hspace="0" vspace="0">Browser not compatible. </iframe>
我还在 CSS 中设置了 display: none。
这让它在 iOS 上为我工作。尚未在其他移动浏览器上测试过,但如果您遇到问题,您可以尝试设置 position: absolute, top: -9999px 等。
【讨论】: