2

i need to optimize my site for IE8. And it does not support opacity directly. It can be set using -ms-filter property. In my javascript am changing the opacity using jquery animate(). but how do i use it with -ms-filter

currently am giving this

$('.topbar img').animate({opacity:1, -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"},1500);

but its throwing a JS error. Invalid property obviously. Can anybody help me how to animate in IE8..? Help appreciated.

Harsh Reddy
  • 203
  • 6
  • 14
  • possible duplicate: http://stackoverflow.com/questions/1552020/jquery-animating-opacity-in-ie – feeela Dec 21 '12 at 13:44

2 Answers2

6

try using:

$('.topbar img').animate(
      {
       opacity:1, 
       '-ms-filter': 'progid:DXImageTransform.Microsoft.Alpha(Opacity=100)'
//     ^quotes
      }
  ,1500);

See also...

Actually, using jquery, you shouldn't need the -ms-filter property. See this jsfiddle for an example

Community
  • 1
  • 1
KooiInc
  • 119,216
  • 31
  • 141
  • 177
0

jQuery have a step() callback that gets triggered in every step of the animation.

$('.topbar img').animate({
  opacity: 1
},
{
  step: function(now, fx) {
    // Every step of the opacity animation we'll get the current 
    // opacity as the 'now' argument.
    var opacity = Math.round(now * 100);
    $(fx.elem).css('-ms-filter', 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + opacity + ')');
  }
});
antila
  • 364
  • 1
  • 4