Welcome Guest [Log In] [Register]
Welcome to RealEmotion. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
PNG Transparency in Internet Explorer; Finally!!!
Topic Started: Apr 10 2006, 03:23 PM (541 Views)
Lamp
Member Avatar

Members
Ok I was researching a little bit and I found this very helpfully:
Code:
 
/*

Correctly handle PNG transparency in Win IE 5.5 & 6.
http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.

Use in <HEAD> with DEFER keyword wrapped in conditional comments:
<script defer type="text/javascript" src="pngfix.js"></script>

*/

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
     }
  }
}
Offline Profile Quote Post Goto Top
 
Haze

Members
Nice find there :)
I dont use IE anyway, but still good for those who do.

//Haze
Offline Profile Quote Post Goto Top
 
+Kaji
Member Avatar
Warrior-FX Member
Elite Member
Kool, i didn't know this code was out... Thanks for posting it, now I can put good quality pictures on ym site and people viewing it through IE will see it correctly.

Once again, thanks!!!!!!
Offline Profile Quote Post Goto Top
 
wildstyles
Member Avatar

Members
whats it do
Offline Profile Quote Post Goto Top
 
xYunaxFantasiesx
My avie pwns yours.
Administrator
This is what I think it does. You know how on Mozilla Firefox PNG's are transparent if they are suppose to be but not on IE. This codes lets you have PNG's be transparent in IE. Thats what I think.
Offline Profile Quote Post Goto Top
 
+Kaze
Member Avatar
JDM > USDM
Elite Member
Well isin't that the name of the thread..lol..
Offline Profile Quote Post Goto Top
 
+Kaji
Member Avatar
Warrior-FX Member
Elite Member
yea, i tested it and thats what it does. Its a really good code.
Offline Profile Quote Post Goto Top
 
.freak
Member Avatar
<_< Envy. *Aggrivation.* Insanity. @_@
Official Members
how does it work? like does this only work when making a site like you put it in the CSS thing? or is this like something i can put somewhere else?
Offline Profile Quote Post Goto Top
 
Mrs. Housewife

Official Designer
Yeah, it basically takes out the blue part of the PNGs in IE.

No, don't put it in the CSS. Put it in your header tags.

Example:
<HTML>
<HEAD>
put code here.
</HEAD>
<BODY>
</BODY>
</HTML>
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Scripting and Coding Tutorial · Next Topic »
Add Reply