Click to See Complete Forum and Search --> : [RESOLVED] Transparency not transparent


Thiele
11-28-2007, 12:49 PM
When I use GIMP to make a fade out or sharpedge transparency using alpha-layer all I get when showing the image with IE Iget a blue-ish colour and not transparent to the background?

Any suggestions?

I should mention that images are saved as .PNG

TheBearMay
11-28-2007, 02:05 PM
IE historically has had a few problems with PNG transparancy.

What seems to work for me is adding these lines in the <head> section of the html page:

<!--[if lt IE 7.]>
<script defer type="text/javascript" src="fixPNG.js"></script>
<![endif]-->


and saving these lines in the file fixPNG.js:


function correctPNG() // correctly handle PNG alpha transparency in Win IE 5.5 & 6.
{
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
if ((version >= 5.5) && (document.body.filters))
{
for(var i=0; i<document.images.length; i++)
{
var img = document.images[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 = "<span " + imgID + imgClass + imgTitle
+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
img.outerHTML = strNewHTML
i = i-1
}
}
}
}
window.attachEvent("onload", correctPNG);

Thiele
11-29-2007, 01:58 AM
Holy s..t It works.

Thank you so much. A solution I myself never would have been able to create. Javascript is not my strong side(I have not had the chance to learn it yet) so the copy paste'ability (is that a new word) in your reply is awesome.

Best regards
Anders Thiele