IE 5.5 & IE6 PNG Transparency Fix (Prototype required)


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  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

You need to login to post a comment.