TROOZERS talking joomla!
Now that I have the new look and version running, I will go through all the stories and make sure they are relevant and indicate which version of Mambo they are for!
 
Home arrow Joomla arrow HOWTO arrow Explorer PNG Fix
Spacer
spacer
Talking Joomla Spacer Spacer
Troozers
Explorer PNG Fix
Friday, 28 May 2004

howto iconThis article has been translated to Polish, available at mambopl.com

When I was starting to add content to the andy-stewart.com website, I decided to change some of the standard Mambo icons and images with my own - to give it a more personal touch.  I had recently purchased a heap of icon images in PNG format, and decided to use these.

Another reason for using the PNG format, was that I was having issues with the transparencies of GIF images especially when I had defined them with a drop shadow.  I would get little white areas around the shadows which looked rubbish when placing them over coloured backgrounds etc.  PNG promised to do away with these issues - and certainly within Opera and FireFox it did.  Unfortunately Microsoft in all it's wisdom had not implemented the PNG transparencies format properly and I was left with a grey/blue background behing all my PNG images.

A quick trawl via Google found me various solutions to fixing the issue under Internet Explorer, and the code snippet below was the most elegant I found.  Elegant in the fact that if you are not running IE, your browser will completely ignore this code snippet;

 

<!--[if gte IE 5.5000]>
<script language="JavaScript">
function correctPNG()
{
   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]-->

Place the above code in the <head> ... </head> area of your templates index.php, and your blue/grey PNG backgrounds will disappear!  There is a slight delay between loading the page and the PNG transparencies displaying properly - but nothing dramatic.

All we need now is for Microsoft to pull a certain digit out of a certain orifice and code according to standards, and the above will become defunct... until then ;-)

 
< Prev   Next >
Spacer
Latest News
Partner Sites
jh design! banner

 RocketTheme Banner

Projects Completed
Amazon Ad
Bottom
Copyright © 2006, Andy Stewart. All Rights Reserved. Joomla! design by jh! design
Spacer Footer