Your Development & Design Resource
Using PNG, and the cross-browser hack!
12/15/2005 11:55 AM by Chris Toohey
I'm doing a lot of web-work as of late (some using Domino and some not). As a result of this, I've been working with Photoshop moreso now than ever before, as the majority of my work has been marketing-related.
This being said, I'm really starting to push the usage of the PNG format for my images. Before going any further, here's some information on the PNG format:
I only have but a minor enhancement to this, marked below in bold!
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or
for(var i=0; i
var imgName = img.src.toUpperCase()
if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
var imgID = (img.id) ? "id='" + img.id + "' " : ""
var imgClass = (img.className) ? "class='" + img.className + "' " : ""
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
var imgStyle = "display:inline-block;" + img.style.cssText
if (img.align == "left") imgStyle = "float:left;" + imgStyle
if (img.align == "right") imgStyle = "float:right;" + imgStyle
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
var strNewHTML = " + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "(src=\'" + img.src + "\', sizingMethod='scale');\">"
img.outerHTML = strNewHTML
i = i-1
if (window.attachEvent) window.attachEvent("onload", correctPNG);
This checks to see if
window.attachEvent can be ran (if so, the
browser's IE-based) and then sets to
correctPNG() function to run
onload of the body!