IE PNG – The PNG Transparency Problem in Windows Internet Explorer

,
  • Digg
  • Technorati
  • del.icio.us
  • Propeller
  • StumbleUpon
  • Reddit
  • Mixx
  • Fark
  • Slashdot
  • Sphinn
  • Design Float
  • DZone
  • BlinkList
  • email
August 27th, 2006 | Web Development How-to's | 2 Comments

As many web developers may already know, several versions of Windows Internet Explorer (IE), cannot properly render PNG image transparencies. There are many CSS hacks and tricks out there to skirt this issue, most often by using less sexy graphics specific for IE browsers.

There is also a lesser known way of fixing the IE problem using a few simple lines of JavaScript.

The only downside to the JavaScript solution is that it only works on <img> elements, and does not work on background images or images placed with a style sheet. Also, the images must have their height and width attributes defined in the HTML.

The following JavaScript code is made available by ntlworld.com:

To use this code, simply call the script to the file in need of the fix and be certain your PNG images have the height and width attributes defined.

That’s it!

Enjoy This Article?

Now is your chance to join our growing community! Be the first to know about great new articles like this one. Register for my Email Updates or RSS Feed today!

About the Author

Zach is a marketing consultant and owner of a FL web design and marketing group. He offers graphic design and marketing services, speaks on Internet marketing, and blogs about it all in his free time. (ยป)

Contact Zach: Company Website | Email

Related Posts


Using DIV and SPAN Elements as Clickable Links

Center Absolute Position DIV

HTML Code Bloat – How to eliminate HTML code bloat from your web pages

Filter Yourself From Google Analytics

Allow HTML in WordPress Author Bios


2 Comments

  1. Chris

    August 28, 2006 @ 2:48 pm

    This is a fix I’ve used for Transparent Background images:

    if (navigator.platform == "Win32" && navigator.appName ==
            "Microsoft Internet Explorer" && window.attachEvent) {
    	window.attachEvent("onload", alphaBackgrounds);
    }
    
    function alphaBackgrounds(){
    	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
    	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
    	for (i=0; i

    Reply

  2. PNG image format..what is it good for? « interface design for the web

    September 26, 2006 @ 7:45 am

    [...] An overview of PNG status in different web browsers: Browsers with PNG Support The PNG problem in Windows Internet Explorer IE PNG – The PNG Transparency Problem in Windows Internet Explorer [...]

RSS feed Comments | TrackBack URI

Write Comment