home *** CD-ROM | disk | FTP | other *** search
/ theapplecollection.com / www.theapplecollection.com.tar / www.theapplecollection.com / png.js < prev    next >
Text File  |  2009-12-18  |  1KB  |  25 lines

  1. function correctPNG() 
  2.    {
  3.    for(var i=0; i<document.images.length; i++)
  4.       {
  5.       var img = document.images[i]
  6.       var imgName = img.src.toUpperCase()
  7.       if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
  8.          {
  9.          var imgID = (img.id) ? "id='" + img.id + "' " : ""
  10.          var imgClass = (img.className) ? "class='" + img.className + "' " : ""
  11.          var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
  12.          var imgStyle = "display:inline-block;" + img.style.cssText 
  13.          if (img.align == "left") imgStyle = "float:left;" + imgStyle
  14.          if (img.align == "right") imgStyle = "float:right;" + imgStyle
  15.          if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle        
  16.          var strNewHTML = "<span " + imgID + imgClass + imgTitle
  17.          + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
  18.          + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
  19.          + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
  20.          img.outerHTML = strNewHTML
  21.          i = i-1
  22.          }
  23.       }
  24.    }
  25. window.attachEvent("onload", correctPNG);