File: ie_png_work_around.js

package info (click to toggle)
phpldapadmin 1.1.0.5-6%2Blenny2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 5,008 kB
  • ctags: 3,949
  • sloc: php: 17,735; xml: 1,532; sh: 388; makefile: 46
file content (29 lines) | stat: -rw-r--r-- 750 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function fixIEPNG( img )
{
   img.style.filter =
      "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
      + img.src + "', enabled=true)";
   img.src="blank.gif";
}

function checkPNGs()
{
   // test to see if the browser is IE
   var agent = navigator.userAgent.toLowerCase();
   var is_ie = (( agent.indexOf("msie")  != -1 ) &&
                ( agent.indexOf("opera") == -1 ));

   // if IE, use DirectX to correctly display a PNG
   if ( !is_ie ) return;

   // go through each image in the page and fix them
   for ( var i = 0; i < document.images.length; i++ )
   {
      // only if the image is a png
      var img = document.images[ i ];
      if ( img.src.indexOf( "png" ) != -1 )
         fixIEPNG( img );
   }
}

checkPNGs();