Image-Imlib2 - Re: How to create IE compatible transparent PNG's?

Posted on Tue Feb 22 21:01:48 2005 by geoffalot in response to 141 (See the whole thread of 3)
Re: How to create IE compatible transparent PNG's?
You can handle pngs for IE on the client side, and not worry about the server side. Note - this doesn't work for background images. You need to put the filter code into the css for that to work (http://www.daltonlp.com/daltonlp.cgi?item_type=1&item_id=217). As well, as an fyi, background png images don't work on IE for the Mac, and Netscape 6 all. (if you care about those) Place this code in a global css file. (or at the file level, if you prefer. Code is PHP with ASP tags, customize to perl as you see fit)
<style type="text/css"> <% if (IE){ %> img { visibility:hidden; behavior: url(css/png.htc); } <% } %> </style>
Then save this code as "png.htc". The spacerImage (a transparent gif image) variable needs to be correct for this to work.
<PUBLIC:COMPONENT lightWeight="true"> <PUBLIC:ATTACH EVENT="oncontentready" ONEVENT="filterImage()" /> <SCRIPT LANGUAGE="JScript"> var orignalImage = element.src; var spacerImage = "images/spacer.gif"; var htcCapable = /MSIE ((5\.5)|[6])/.test(navigator.userAgent) && navigator.platform == "Win32"; function filterImage() { if(/\.png$/.test(orignalImage)) { if(htcCapable) { element.src = spacerImage; element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + orig +nalImage + ",sizingMethod='scale')"; } } element.style.visibility = 'visible'; } </SCRIPT> </PUBLIC:COMPONENT>
geoff geoffrey@geoffreymoller.com
Direct Responses: 144 | Write a response