PNGs en Internet Explorer 5.5 o superior

Trucos, Web Add comments

Esto es un truquito para poder visualizar correctamente en el Internet Explorer las imagenes en formato PNG con fondo transparente. Para ello hay que crear un fichero llamado pngfix.js en el servidor con el siguiente script:

function correctPNG()
{
for(var i=0; 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 = " + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + img.src + "\', sizingMethod='scale');\">

img.outerHTML = strNewHTML
i = i-1
}
}
}
window.attachEvent(”onload”, correctPNG);

Despues, en cada pagina donde hay una imagen PNG debemos añadir el siguiente codigo (dentro del head de dicha pagina):

E voila!… ya se veran de forma correcta.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in