You are hereDocumentación / PNGs Transparentes en explorer / Transparent PNGs on explorer

PNGs Transparentes en explorer / Transparent PNGs on explorer


¿Cuantas veces nos ha pasado que hacemos una web con imagenes en formato PNG y luego resulta que en el maltido Internet explorer no son transparentes y nos toca rellenar la transparencia con el color de fondo que corresponde? Pues bien, he aqui la solución.
<!--[if gte IE 5.5000]>
<script language="JavaScript">
function correctPNG()
{
  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
    }
  }
}
window.attachEvent("onload", correctPNG);
</script>
<![endif]-->

Yo creia haberlo encontrado en el codigo HTML de la página del admirabilisimo señor jimmac, pero ya no lo veo, asi que por si acaso hago referencia al lugar donde si que se que está: aqui
Y otra refencia mas xula aún

Enviar un comentario nuevo

El contenido de este campo se mantiene como privado y no se muestra públicamente.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Saltos automáticos de líneas y de párrafos.
  • Las direcciones de las páginas web y las de correo se convierten en enlaces automáticamente.

Más información sobre opciones de formato

CAPTCHA
Esta es una preguntar para comprobar que eres un humano y no un robot de spam.