View Single Post
Old 2009-09-24, 04:52 PM   #11
blinki bill
Are you sure you're an accredited and honored pornographer?
 
Join Date: May 2006
Location: London, UK
Posts: 67
Send a message via ICQ to blinki bill
png transparency work just fine with ie7 and ie8

for older versions like ie6 the best option i think is trough css
instead of having the image in img tag you can just place and empty span and then assign class to this span with the following:

Code:
background:url(noimage.gif);
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='path_to_png_image', sizingMethod='scale');
i have a simple piece of js code that makes this automatically for all the png's on the page (just place it before the ending body tag):
Code:
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
 var ieversion=new Number(RegExp.$1)

 if (ieversion == 7) 
{
   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
      }
   }
}
__________________
I'm looking for the question about the life, the universe and everything else
blinki bill is offline   Reply With Quote