PDA

View Full Version : Forum Home Enhancements - fix png transparency


RC.
26 May 2008, 02:53
this code fix the png transparency problems whit ie5 and ie 6

this is very simple:
in the header template add this code very top:



<!--[if gte IE 5.5000]>
<script language="JavaScript">
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
{
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 + "\');\"></span>"
img.outerHTML = strNewHTML
i = i-1
}
}
}
window.attachEvent("onload", correctPNG);
</script>
<![endif]-->





If you Like This Mod Mark INSTALLED (http://www.vbulletin.org/forum/vborg_miscactions.php?do=installhack&threadid=180509)

enjoy

dvbusuario
26 May 2008, 03:04
Install!!

Bonus Paradise
26 May 2008, 08:26
thank you for that! :)

Silvio
26 May 2008, 12:31
ty sir! *installed

echo2kk5
26 May 2008, 17:32
Does this work with 32 bit PNG images as well?

OcR Envy
27 May 2008, 11:53
Any problems with width/height going crazy? I've tried other png ie fixes that worked but had issues.

Wayne Luke
27 May 2008, 16:35
This solution is more elegant, less resource intensive and still valid:

http://www.vbulletin.org/forum/showthread.php?t=94416

Just by placing the javascript in an external file, you can significantly reduce page load and bandwidth simply because its cached in the end-user's browser. Not only that but IE7 and IE8 do not need this applied to PNG images since they support the Alpha Transparency natively.

OsiRiS_X
20 Jun 2008, 18:28
Install, Very Nice!

kencasanova
21 Jun 2008, 18:16
it doesn't work with mine. help!

CMGU
21 Jun 2008, 19:08
doesn't work for me

mesdar
12 Dec 2008, 07:59
thanks

installed