[905] | 1 | |
---|
| 2 | // Correctly handle PNG transparency in Win IE 5.5 or higher. |
---|
| 3 | // http://homepage.ntlworld.com/bobosola. Updated 02-March-2004 |
---|
[1472] | 4 | // 15-Jully-2006 : chrisaga use \" instead of ' in imgTitle |
---|
| 5 | // : to fix ' display in tooltips |
---|
| 6 | // : keep the alt attribute |
---|
[905] | 7 | |
---|
| 8 | function correctPNG() |
---|
| 9 | { |
---|
| 10 | for(var i=0; i<document.images.length; i++) |
---|
| 11 | { |
---|
[948] | 12 | var img = document.images[i] |
---|
[8362] | 13 | //if (img.className == "button" || img.className == "icon") |
---|
[948] | 14 | { |
---|
[905] | 15 | var imgName = img.src.toUpperCase() |
---|
| 16 | if (imgName.substring(imgName.length-3, imgName.length) == "PNG") |
---|
| 17 | { |
---|
| 18 | var imgID = (img.id) ? "id='" + img.id + "' " : "" |
---|
| 19 | var imgClass = (img.className) ? "class='" + img.className + "' " : "" |
---|
[1472] | 20 | //var imgTitle = (img.title) ? "title=\"" + img.title + "\" " : "alt=\"" + img.alt + "\" " |
---|
| 21 | var imgTitle = (img.title) ? "title=\"" + img.title + "\" " : ""; |
---|
| 22 | imgTitle = imgTitle + (img.alt) ? "title=\"" + img.alt + "\" " : ""; |
---|
[905] | 23 | var imgStyle = "display:inline-block;" + img.style.cssText |
---|
| 24 | if (img.align == "left") imgStyle = "float:left;" + imgStyle |
---|
| 25 | if (img.align == "right") imgStyle = "float:right;" + imgStyle |
---|
| 26 | if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle |
---|
| 27 | var strNewHTML = "<span " + imgID + imgClass + imgTitle |
---|
| 28 | + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" |
---|
| 29 | + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" |
---|
| 30 | + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" |
---|
| 31 | img.outerHTML = strNewHTML |
---|
| 32 | i = i-1 |
---|
| 33 | } |
---|
[948] | 34 | } |
---|
[905] | 35 | } |
---|
| 36 | } |
---|
[948] | 37 | window.attachEvent("onload", correctPNG); |
---|