Web :: Browser issues :: Knowledge Base : how to make PNG images transparent under Internet Explorer ? Fix the bug with transparency. |
|||
| By: VGR |
Date: 02/05/2006 10:14:37 |
Points: 0 | Status: Answered Quality : Excellent |
|
Answer : Just generate HTML like this : <!--[if gte IE 5.5000]> <script type="text/javascript" src="pngfix.js"></script> <![endif]--> NB this KB entry uses this other one The pngfix.js file would contain : // Correctly handle PNG transparency in Win IE 5.5 or higher. // http://homepage.ntlworld.com/bobosola. Updated 02-March-2004 //VGR01052006 MOD beautified (indentation, code style, comments) function correctPNG() { for(var i=0; i<document.images.length; i++) { var img = document.images; 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 } // if PNG } // for images } // Procedure correctPNG window.attachEvent("onload", correctPNG); |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








