source: trunk/themes/default/js/pngfix.js @ 8362

Last change on this file since 8362 was 8362, checked in by rvelices, 13 years ago
  • css sprites work for ie6
  • simplify/remove css
  • Property svn:eol-style set to LF
File size: 1.6 KB
Line 
1
2// Correctly handle PNG transparency in Win IE 5.5 or higher.
3// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004
4// 15-Jully-2006 : chrisaga use \" instead of ' in imgTitle
5//               : to fix ' display in tooltips
6//               : keep the alt attribute
7
8function correctPNG() 
9   {
10   for(var i=0; i<document.images.length; i++)
11      {
12      var img = document.images[i]
13      //if (img.className == "button" || img.className == "icon")
14          {
15          var imgName = img.src.toUpperCase()
16          if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
17             {
18                 var imgID = (img.id) ? "id='" + img.id + "' " : ""
19                 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
20                 //var imgTitle = (img.title) ? "title=\"" + img.title + "\" " : "alt=\"" + img.alt + "\" "
21                 var imgTitle = (img.title) ? "title=\"" + img.title + "\" " : "";
22                 imgTitle = imgTitle + (img.alt) ? "title=\"" + img.alt + "\" " : "";
23                 var imgStyle = "display:inline-block;" + img.style.cssText 
24                 if (img.align == "left") imgStyle = "float:left;" + imgStyle
25                 if (img.align == "right") imgStyle = "float:right;" + imgStyle
26                 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle               
27                 var strNewHTML = "<span " + imgID + imgClass + imgTitle
28                 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
29             + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
30                 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
31                 img.outerHTML = strNewHTML
32                 i = i-1
33             }
34          }
35      }
36   }
37window.attachEvent("onload", correctPNG);
Note: See TracBrowser for help on using the repository browser.