【问题标题】:Trying to change background color of iFrame in IE尝试在 IE 中更改 iFrame 的背景颜色
【发布时间】:2011-05-20 08:25:42
【问题描述】:

我有一个使用 iFrame 的网页(请参阅 http://little-apps.org/lilregcleaner/history.html),并且(当然)iFrame 在 IE 中显示为白色背景,而不是在 firefox 和 chrome 中显示为蓝色背景。我已经尽一切努力使 iframe 蓝色/透明的背景包括:

  • 将“allowtransparency=true”标签添加到 iframe
  • 使用 javascript 在 iframe 内部添加“背景颜色:蓝色”和“背景颜色:透明”标签
  • 用“background-color: blue”将 iframe 括在 span 标签中
  • 将 iframe 更改为 div(不起作用,因为我使用 AJAX 从 XML 文件中获取源,并且 XMLHttpRequest 对象只能使用一次)

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

谢谢!

【问题讨论】:

    标签: javascript html css internet-explorer iframe


    【解决方案1】:

    将 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
    

    【讨论】:

    • 将 IFRAME BODY 的背景设置为transparent 也可以在 IE 中工作。没试过。
    【解决方案2】:

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

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

    【讨论】:

    • 谢谢!看起来这是唯一的方法,即使它需要一些工作。
    猜你喜欢
    • 1970-01-01
    • 2013-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-06
    • 2012-01-23
    • 2013-08-08
    相关资源
    最近更新 更多