Foros del Web » Programando para Internet » Javascript »

Visualizar Correctamente PNG - IExplorer

Estas en el tema de Visualizar Correctamente PNG - IExplorer en el foro de Javascript en Foros del Web. Hola gente como andan? acá les paso un cod en javascript que encontre muy interesante para aquellos que les gusta el PNG como a mí, ...
  #1 (permalink)  
Antiguo 21/11/2006, 16:11
 
Fecha de Ingreso: noviembre-2003
Ubicación: Asuncion
Mensajes: 76
Antigüedad: 20 años, 5 meses
Puntos: 1
Sonrisa Visualizar Correctamente PNG - IExplorer

Hola gente como andan? acá les paso un cod en javascript que encontre muy interesante para aquellos que les gusta el PNG como a mí, el mismo permite mostrar correctamente las transparencias de png en internet explorer.

Si este código ya fue posteado, moderadores favor borrar este topic

Código:
<script language="JavaScript">
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
   {
   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 + "\');\"></span>" 
         img.outerHTML = strNewHTML
         i = i-1
         }
      }
   }
window.attachEvent("onload", correctPNG);
</script>
Espero haya sido de su agrado!! Salu2
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:14.