DRC - Digital reality crew logo
DRC Forum | Register | Log in | Forum help | Search

PNG Transparency fix


DRC Forum
» Community Forums
    » Forum Improvement Suggestions
        » PNG Transparency fix
            » Page 1 of 1

  Post new topicReply to topic

Author Message
|DRC| Death






Saturday, October 7 2006, 17:23:02 #36853     PNG Transparency fix


As you can see, me and Messiah both use avatars that are png and use transparency. Firefox displays them fine but it buggers up in IE. I have code to fix it, it's in JavaScript format. I dunno if you can cross PHP with JavaScript but it'd be pretty cool to fix it.

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:
<if>
<script></script>
<endif>

*/

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></span>"
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}


That's the JS code.

Code:

<script></script>


You need this in the actual page you want to display it on. It has to go in the <head> tag.
Profile | Send PM | AIM | YIM | MSN | ICQ
 
Sponsored Ad






Today #     Sponsored Ads


WWW
 
Display posts from previous:   


Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Optimized with phpBB SEO
Questions? Contact us at fubar_54-198-23-251@wartex.net