[英]-ms-filter with javascript
How do I implement the -ms-filter in javascript? 如何在JavaScript中实现-ms-filter?
I tried the following which does not work: 我尝试了以下无效的方法:
document.getElementById(ba[i]).style.sFilter =
'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + value*10 + ')';
Another question. 另一个问题。 If I want to change the font color of an element I used the following (which worked in everything except IE8 again): 如果要更改元素的字体颜色,可以使用以下内容(再次适用于IE8以外的所有内容):
document.getElementById(ba[i]).style.color = '#B4D8FD';
Here is your reference: 这是您的参考:
http://msdn.microsoft.com/en-us/library/ms532847(VS.85).aspx http://msdn.microsoft.com/en-us/library/ms532847(VS.85).aspx
If you want to use -ms-filter, use these 如果要使用-ms-filter,请使用这些
Notice, that the css filter must be defined at the item either as an inline style attribute or by a class, else the filters.item property is inaccessible!! 注意,css过滤器必须在项目中定义为内联样式属性或由类定义,否则无法访问filters.item属性!
Some example code: 一些示例代码:
<style>
.macska
{
opacity:1;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
filter:alpha(opacity=100);
}
</style>
<div id="xxx" style="background-color: #CCC; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=100)" class="macska">
CONTENT
</div>
<script>
o = document.getElementById('xxx');
o.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 20;
</script>
This wont work: 这将无法工作:
<style>
.macska
{
opacity:1;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
filter:alpha(opacity=100);
}
</style>
<div id="xxx" style="background-color: #CCC;>
CONTENT
</div>
<script>
o = document.getElementById('xxx');
o.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 20;
</script>
尝试使用cssText
属性。
document.getElementById(ba[i]).cssText = 'color:#B4D8FD; filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=' + value*10 + ');';
The first question i think yuo can do 我认为你能做的第一个问题
document.getElementById(ba[i]).style['-ms-filter'] = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + value*10 + ')';
And for question 2 try the above method aswell. 对于问题2,也请尝试上述方法。
document.getElementById(ba[i]).style['color'] = '#B4D8FD';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.