IE 5.5 & IE6 PNG Transparency Fix (Prototype required)


 / Published in: JavaScript
 

  1. // this will iterate with each element with the class 'ie-fix-opacity' and add an IE filter,
  2. // replacing the background-image for the filter of that image
  3. var version = parseFloat(navigator.appVersion.split('MSIE')[1]);
  4. if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
  5. document.getElementsByClassName('ie-fix-opacity').each(function(poElement){
  6. // if IE5.5+ on win32, then display PNGs with AlphaImageLoader
  7. var cBGImg = poElement.currentStyle.backgroundImage;
  8. var cImage = cBGImg.substring(cBGImg.indexOf('"') + 1, cBGImg.lastIndexOf('"'));
  9.  
  10. poElement.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + cImage + "', sizingMethod='scale')";
  11. poElement.style.backgroundImage = "none";
  12. });
  13. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: alvaroisorna on July 27, 2006

hey! this is the same as my scriplet!! please at least make a comment about it..

http://snipplr.com/view/125/png-opacity-support-for-internet-explorer-simplified/

You need to login to post a comment.