| 1 |
/* $Id: pngfix.js,v 1.2 2005/08/29 21:52:13 robinmonks Exp $ */
|
| 2 |
|
| 3 |
// Correctly handle PNG transparency in Win IE 5.5 or higher.
|
| 4 |
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004
|
| 5 |
// updated 2005-05-11 to test for IE
|
| 6 |
|
| 7 |
function correctPNG() {
|
| 8 |
if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("Opera") == -1 && window.attachEvent) {
|
| 9 |
for(var i=0; i<document.images.length; i++) {
|
| 10 |
var img = document.images[i]
|
| 11 |
var imgName = img.src.toUpperCase()
|
| 12 |
if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
|
| 13 |
var imgID = (img.id) ? "id='" + img.id + "' " : ""
|
| 14 |
var imgClass = (img.className) ? "class='" + img.className + "' " : ""
|
| 15 |
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
|
| 16 |
var imgStyle = "display:inline-block;" + img.style.cssText
|
| 17 |
if (img.align == "left") imgStyle = "float:left;" + imgStyle
|
| 18 |
if (img.align == "right") imgStyle = "float:right;" + imgStyle
|
| 19 |
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
|
| 20 |
var strNewHTML = "<span " + imgID + imgClass + imgTitle
|
| 21 |
+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
|
| 22 |
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
|
| 23 |
+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
|
| 24 |
img.outerHTML = strNewHTML
|
| 25 |
i = i-1
|
| 26 |
}
|
| 27 |
}
|
| 28 |
}
|
| 29 |
}
|
| 30 |
if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("Opera") == -1 && window.attachEvent) {
|
| 31 |
window.attachEvent("onload", correctPNG);
|
| 32 |
}
|