尝试在IE中更改iFrame的背景颜色

Trying to change background color of iFrame in IE

本文关键字:iFrame 背景 颜色 IE      更新时间:2023-09-26

我有一个使用iFrame的网页(见 http://little-apps.org/lilregcleaner/history.html),(当然)iFrame在IE中显示为白色背景,而不是Firefox和chrome中的蓝色背景。我已经尝试了一切使iframe的背景蓝色/透明,包括:

  • 将"允许透明度=true"标记添加到 iframe
  • 使用 JavaScript 在 iframe 内部添加"background-color: blue"和"background-color: transparent"标签
  • 将 iframe 括在带有"背景颜色:蓝色"的 span 标记中
  • 将 iframe 更改为div(不起作用,因为我使用 AJAX 从 XML 文件中获取源代码,而 XMLHttpRequest 对象只能使用一次)

如果有人知道我的问题的解决方案,请告诉我。我还应该指出,我唯一的成功是使用style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0)"。

谢谢!

将 IFRAME BODY 的 style 属性设置为 background-color:blue 在 IE8 的调试器中对我有用。(即,在 IFRAME 中加载的文档的正文。

或者,您可以使用 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

我认为您必须在iframe中加载的页面中添加背景。

示例,修改 http:/little-apps.org/lilregcleaner/history/1.xx.html