【问题标题】:Code doesn't work on IE6 if i click a button to open a popup form [closed]如果我单击按钮打开弹出表单,代码在 IE6 上不起作用[关闭]
【发布时间】:2014-05-21 14:15:27
【问题描述】:

我的代码在 firefox 上运行良好,但在 IExplorer 6 上却不行 我的部分代码是:

document.getElementById('layout').style.opacity = .7
document.getElementById('layout').style.display = "block"

【问题讨论】:

  • 解决问题的方法是放弃对 IE6 的支持。这对less than 0.3% 的用户来说是不值得的。
  • @Joeytje50 即使您是对的,也无济于事。 OP:你的问题是什么?
  • caniuse.com/#search=opacity -- opacity 仅适用于 ie9+
  • @Markus 这就是为什么我将其发布为评论,而不是答案。
  • 刚刚注意到注释:Transparency for elements in IE8 and older can be achieved using the proprietary "filter" property and does not work well with PNG images using alpha transparency. -- 见@sjkm 的回答。

标签: javascript css internet-explorer-6


【解决方案1】:

这应该在 IE 6 中工作:

filter: alpha(opacity=70);

但是,如前所述,您应该仅在必要时支持 IE 6。

更新

就像 Joeytje50 所写,您还可以另外添加 -ms-filter 属性:

-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";

filter 属性适用于所有 IE 版本,而-ms-filter 在 IE8+ 中受支持

取自 msdn.microsoft.com: -ms-filter 属性是 CSS 的扩展,可以用作 IE8 标准模式下过滤器的同义词。当您使用 -ms-filter 时, 用单引号 (') 或双引号 (") 将 progid 括起来。使用 逗号 (,) 分隔多个值。

【讨论】:

【解决方案2】:

首先需要通过编写javascript代码来获取浏览器

var browser=navigator.appName //get Browser name 

然后为不同的浏览器设置不透明度

if(browser=="Netscape")  //For mozilla firefox
{
document.getElementById('layout').style.opacity = .7;   
}

if(browser=="Microsoft Internet Explorer")
{
document.getElementById('layout').style.filter:alpha(opacity=70); /* IE 5-7 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
}

您可以访问我的博客以获取更多参考http://cshotopics.blogspot.in/2014/02/interactive-form-design-using-css-jquery.html

【讨论】:

  • 虽然你的答案很好..但是这段代码也很可观.. document.getElementById("layout").className = "transparent_class"; with css .transparent_class { /* IE 8 / -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; / IE 5-7 / filter: alpha(opacity=70); / 网景 / -moz-opacity: 0.7; / Safari 1.x / -khtml-opacity: 0.7; / 好的浏览器 */ opacity: 0.7; }
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-04-07
  • 1970-01-01
  • 1970-01-01
  • 2022-11-13
  • 1970-01-01
  • 1970-01-01
  • 2019-12-11
相关资源
最近更新 更多