Posted By

conspirator on 09/26/08


Tagged

javascript png textmate


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

bassdas
chippper


PNG Support - NO OTHER FILES NEEDED


 / Published in: Other
 

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

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: bassdas on October 9, 2008

Thanks, it works in my code with following modification:

var strNewHTML = "";

Posted By: bassdas on October 9, 2008

Thanks for your snippet. We have done an modified snippet in base of your snippet: http://cms4.blogspot.com/2008/10/png-support-im-alten-internet-explorer.html

You need to login to post a comment.