# .PNG images not showing in IE



## tdi_veedub (Jan 29, 2004)

I have applied a javascript fix to some transparent .png files laid out in a table and they show up great on Firefox, IE 6 and Netscape 7 on my computers at home.

However, I when try to view the page at work with IE 6 and the .png images show and then disappear as soon as the javascript is applied. Also at work, netscape 4.77 shows a black background where the transparency is supposed to be. I have checked other sites and it is the same thing, at home they look perfect. At work, nothing. I don't care as much about netscape 4.x support as I do for IE. Am I fighting a lost cause here or is it just something about this antiquated NT4 sp4 setup at work?

I added the following to the page source:



and this is the script:

// Correctly handle PNG transparency in Win IE 5.5 or higher.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004

function correctPNG() 
{
for(var i=0; i<document.images.length; i++)
{
var img = document.images_
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 = "" 
img.outerHTML = strNewHTML
i = i-1
}
}
}
window.attachEvent("onload", correctPNG);_


----------



## Cookies (Jul 3, 2003)

Have you tried opening the. png image with a photo editor and using File, Save as and choosing .gif as the file extension? Try one, upload, change the source code, and see if this resolves your issue. The image resolution could be different as well.


----------



## tdi_veedub (Jan 29, 2004)

At this point I have resorted to adding a background layer for compatability with older browsers. The reason I wanted to use .png is the 24-bit color support for my graphics. So much for saving time when I change the page but keep my buttons...*sigh*


----------



## Cookies (Jul 3, 2003)

Well I'm not the image guru; don't be sad. Perhaps someone might have an alternative we haven't yet thought of?


----------

