Header image background

Need help with forum functions? Posting a picture, updating your profile, etc. Problem reports go here as well.

Header image background

Postby krnl » 05 Sep 2008, 13:58

There was a problem with the header image in this site when using Internet Explorer (IE). The three anchors image has a transparent background. It looked great in FireFox. Unfortunately, I didn't realize that it looked like p00 in IE!! So, I just opened the site in IE today and there it was... non-transparent - transparent background on that image! So, I did a little searching and found a nice little javascript that does the job fixing my transparency problem. here's the code (for future reference!)

Code: Select all
<!--[if lt IE 7]>
<script language="JavaScript">
function correctPNG() // correctly handle PNG 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);
</script>
<![endif]-->

:pirate: Go Navy! :pirate:

Rick Sandlin (Formerly FCC(SW))
Image
User avatar
krnl
Site Admin
 
Posts: 420
Joined: 17 Apr 2008, 20:45
Location: Dahlgren, VA
Date you made Chief: 14Sep2001
Current Rate/Rank: FCC(SW)(RE-R1)
First Name: Rick
Duty Station: ATRC Dahlgren, VA
Duty Status: Honorably Discharged

Return to Questions, Comments, Problems, etc

Who is online

Users browsing this forum: No registered users and 0 guests

cron