开发者

-ms-filter with javascript

How do I implement the -ms-filter in javascript?

I tried the following which does not work:

document.getElementById(ba[i]).style.sFilter = 
      'progid:DXImageT开发者_如何学Cransform.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):

document.getElementById(ba[i]).style.color = '#B4D8FD';


Here is your reference:

http://msdn.microsoft.com/en-us/library/ms532847(VS.85).aspx

If you want to use -ms-filter, use these

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!!

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>


Try using the cssText attribute.

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.

document.getElementById(ba[i]).style['color'] = '#B4D8FD';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜