0

I am trying to work around with the background size property in IE 7 and IE 8. I know they don't support it and I am trying to use AlphaImageLoader for my solution. I want to change the image source dynamically in javascript but I am not sure how. Here are my codes.

  var div = document.createElement('div');
  var imgSrc ='/images/' + image;

  div.className = 'div_element';
  div.style.width = '112px';
  div.style.height = '100px';
  div.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=imgSrc, sizingMethod='scale')";

The whole codes don't work. There is no images shown in IE. Are there anyways to do this? Thanks a lot!

Rouge
  • 4,181
  • 9
  • 28
  • 36
  • See my question here: http://stackoverflow.com/questions/10142491/alternative-for-background-sizecover-in-ie7 – ediblecode May 01 '13 at 16:20

1 Answers1

1

Try this polyfill from Louis Remi which affords IE versions background-size abilities. It works wonders for me on my projects. It's a simple .htc file (and maybe an .htaccess file, depending on your server configuration).

https://github.com/louisremi/background-size-polyfill

MikeZ
  • 858
  • 1
  • 7
  • 20