How do I implement the -ms-filter in javascript?
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):
document.getElementById(ba[i]).style.color = '#B4D8FD';
How do I implement the -ms-filter in javascript?
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):
document.getElementById(ba[i]).style.color = '#B4D8FD';
Share
edited Jul 1, 2010 at 17:45
Michael Petrotta
61k27 gold badges152 silver badges181 bronze badges
asked Jul 1, 2010 at 17:42
nickynicky
8172 gold badges14 silver badges27 bronze badges
3 Answers
Reset to default 6Here is your reference:
http://msdn.microsoft./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';
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744918052a4600958.html
评论列表(0条)