<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Catzie.net Blog &#187; PNG images</title>
	<atom:link href="http://blog.catzie.net/tag/png-images/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.catzie.net</link>
	<description>Programming, Networking, and other Downloads by Catzie</description>
	<lastBuildDate>Tue, 07 Feb 2012 15:19:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Fix PNG images with transparency in older Windows Internet Explorer versions</title>
		<link>http://blog.catzie.net/fix-png-images-with-transparency-in-older-windows-internet-explorer-versions/</link>
		<comments>http://blog.catzie.net/fix-png-images-with-transparency-in-older-windows-internet-explorer-versions/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 06:49:31 +0000</pubDate>
		<dc:creator>Catzie</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PNG images]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://blog.catzie.net/?p=251</guid>
		<description><![CDATA[I wonder if this post would still get hits from search engine result pages. So many other web pages feature this fix for IE 5.5 and IE 6 web browser, that the Catzie.net Blog&#8217;s entry might just show up on the&#8230; 10th page or so. lol. Anyways, I&#8217;m still posting this, in case there are [...]]]></description>
			<content:encoded><![CDATA[<p>I wonder if this post would still get hits from search engine result pages. So many other web pages feature this fix for <strong>IE 5.5 and IE 6</strong> web browser, that the Catzie.net Blog&#8217;s entry might just show up on the&#8230; 10th page or so. lol.</p>
<p>Anyways, I&#8217;m still posting this, in case there are some visitors browsing around who need help with properly displaying the transparency of <strong>.PNG</strong> images in <strong>IE5.5 and IE6</strong>. This also helps me easily find the needed code to fix the display. I need it from time to time when I design website layouts. <img src='http://blog.catzie.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span style="color: red;">Tip:</span> Most of us are probably using the newer versions of Internet Explorer. I suggest that you <a href="http://blog.catzie.net/ie-tester-see-how-your-web-pages-look-in-different-versions-of-ie-windows-internet-explorer/">download and use the IE Tester</a>. It&#8217;s a web browser that lets you see how web pages render in different versions of IE &#8211; 5.5, 6, 7, and 8.</p>
<p>I assume that as you read this, you are using Internet Explorer version 5.5, or the version 5.5 tab on the <a href="http://blog.catzie.net/ie-tester-see-how-your-web-pages-look-in-different-versions-of-ie-windows-internet-explorer/">IE Tester</a>.<br />
<span id="more-251"></span><br />
The following .png image has a grayish background color that replaces the parts that are supposed to be transparent.</p>
<div style="background:pink;padding:20px;">
<img src="http://img.photobucket.com/albums/v209/catzie/transparent1.png" alt="" />
</div>
<p>This is the code for what&#8217;s show above.</p>
<pre name="code" class="xml">
&lt;div style="background:pink;padding:20px;"&gt;
&lt;img src="http://img.photobucket.com/albums/v209/catzie/transparent1.png"
alt="" /&gt;
&lt;/div&gt;
</pre>
<p><a href="../pages/html/PNGtransparencyIE.html" target="_blank">Please click here</a> to open on a new window the fixed version of what we are trying to display. You&#8217;d notice that there&#8217;s no longer the  grayish background on the parts that are supposed to be transparent. Now you can see through the pink background.</p>
<p>The final code is:</p>
<pre name="code" class="xml">
&lt;html&gt;
&lt;head&gt;
	&lt;style type="text/css"&gt;
		body{
			background-color:pink;
		}
	&lt;/style&gt;
&lt;!--[if lt IE 7]&gt;
&lt;script language="JavaScript"&gt;
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 &#038; 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version &gt;= 5.5) &#038;&#038; (document.body.filters))
   {
      for(var i=0; i&lt;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 = "&lt;span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height
            + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"&lt;&gt;/span&gt;"
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }
}
window.attachEvent("onload", correctPNG);
&lt;/script&gt;
&lt;![endif]--&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;div style="background:pink;padding:20px;"&gt;
         &lt;img src="http://img.photobucket.com/albums/v209/catzie/transparent1.png"
                alt="" /&gt;
  &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>The code above uses <b>conditional comment</b> to check if your current browser is older than IE 7. If it is, the JavaScript code which corrects the display of the .png is executed.</p>
<p>This method has limitations though. It works only on IE5.5 and IE6. It needs JavaScript enabled on your browser, or else it won&#8217;t work. And it only works on images placed using the &lt;img&gt; tag. It won&#8217;t work on background images.</p>
<p>I learned about this fix from <a href="http://homepage.ntlworld.com/bobosola" rel="nofollow" onclick="pageTracker._trackPageview('/outgoing/homepage.ntlworld.com/bobosola?referer=');">this website</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.catzie.net/fix-png-images-with-transparency-in-older-windows-internet-explorer-versions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

