3 Correctly handle PNG transparency in Win IE 5.5 & 6.
4 http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.
6 Use in <HEAD> with DEFER keyword wrapped in conditional comments:
8 <script defer type="text/javascript" src="pngfix.js"></script>
13 var arVersion
= navigator
.appVersion
.split("MSIE")
14 var version
= parseFloat(arVersion
[1])
16 if ((version
>= 5.5) && (document
.body
.filters
))
18 for(var i
=0; i
<document
.images
.length
; i
++)
20 var img
= document
.images
[i
]
21 var imgName
= img
.src
.toUpperCase()
22 if (imgName
.substring(imgName
.length
-3, imgName
.length
) == "PNG")
24 var imgID
= (img
.id
) ? "id='" + img
.id
+ "' " : ""
25 var imgClass
= (img
.className
) ? "class='" + img
.className
+ "' " : ""
26 var imgTitle
= (img
.title
) ? "title='" + img
.title
+ "' " : "title='" + img
.alt
+ "' "
27 var imgStyle
= "display:inline-block;" + img
.style
.cssText
28 if (img
.align
== "left") imgStyle
= "float:left;" + imgStyle
29 if (img
.align
== "right") imgStyle
= "float:right;" + imgStyle
30 if (img
.parentElement
.href
) imgStyle
= "cursor:hand;" + imgStyle
31 var strNewHTML
= "<span " + imgID
+ imgClass
+ imgTitle
32 + " style=\"" + "width:" + img
.width
+ "px; height:" + img
.height
+ "px;" + imgStyle
+ ";"
33 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
34 + "(src=\'" + img
.src
+ "\', sizingMethod='scale');\"></span>"
35 img
.outerHTML
= strNewHTML