我有一个使用 iFrame 的网页(请参阅 http://little-apps.org/lilregcleaner/history.html )并且(当然)iFrame 在 IE 中显示为白色背景,而不是在 Firefox 和 Chrome 中显示为蓝色背景。我已尝试一切使 iframe 的背景变为蓝色/透明,包括:
- 将“allowtransparency=true”标签添加到 iframe
- 使用 JavaScript 将“背景颜色:蓝色”和“背景颜色:透明”标记添加到 iframe 内部
- 将 iframe 包含在带有“background-color: blue”的 span 标记中
- 将 iframe 更改为 div(不起作用,因为我使用 AJAX 从 XML 文件获取源,并且 XMLHttpRequest 对象只能使用一次)
如果有人知道我的问题的解决方案,请告诉我。我还应该注意到,我唯一的成功是 style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0)"。
谢谢!
最佳答案
将 IFRAME BODY 的 style
属性设置为 background-color:blue
在 IE8 的调试器中对我有用。 (即 IFRAME 中加载的文档的 BODY。)
或者,您可以使用 JavaScript 直接更改 BODY 的样式:
document.getElementById("versionHistory").contentWindow.document.body.style.backgroundColor="blue";
// get the IFRAME window object, get the BODY tag in that window, set its CSS
关于javascript - 尝试更改 IE 中 iFrame 的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6066235/