Posted By

trickychicken on 09/25/06


Tagged

fix ie png


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

luman
vaaaska
ebukva
vali29


PNG ie fix


 / Published in: JavaScript
 

  1. /*
  2.  
  3. Include in the header:
  4.  
  5. <!--[if lt IE 7.]>
  6. <script defer type="text/javascript" src="pngfix.js"></script>
  7. <![endif]-->
  8. */
  9.  
  10. var arVersion = navigator.appVersion.split("MSIE")
  11. var version = parseFloat(arVersion[1])
  12.  
  13. if ((version >= 5.5) && (document.body.filters))
  14. {
  15. for(var i=0; i<document.images.length; i++)
  16. {
  17. var img = document.images[i]
  18. var imgName = img.src.toUpperCase()
  19. if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
  20. {
  21. var imgID = (img.id) ? "id='" + img.id + "' " : ""
  22. var imgClass = (img.className) ? "class='" + img.className + "' " : ""
  23. var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
  24. var imgStyle = "display:inline-block;" + img.style.cssText
  25. if (img.align == "left") imgStyle = "float:left;" + imgStyle
  26. if (img.align == "right") imgStyle = "float:right;" + imgStyle
  27. if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
  28. var strNewHTML = "<span " + imgID + imgClass + imgTitle
  29. + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
  30. + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
  31. + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
  32. img.outerHTML = strNewHTML
  33. i = i-1
  34. }
  35. }
  36. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: trickychicken on September 25, 2006

this goes in the header

You need to login to post a comment.