PNG Support - NO OTHER FILES NEEDED


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



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

You need to login to post a comment.