Medicine for your IE6/PNG headache!
DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
Author: Drew Diller
Email: drew.diller@gmail.com
URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/
Version: 0.0.7a
DD_belatedPNG is free software under the MIT License. Please familiarize yourself with known issues.
This is a Javascript library that sandwiches PNG image support into IE6 without much fuss. You can use PNGs as the SRC of an <IMG/> element or as a background-image property in CSS.
If you attempt the latter, you will find that, unlike with vanilla usage of AlphaImageLoader, background-position and background-repeat work as intended.
As a bonus, “fixed” elements will respond to a commonly used set of Javascript style assignments, as well as the A:hover pseudo-class.
Long story short, this uses Microsoft's implementation of VML instead of Microsoft's AlphaImageLoader filter. I stumbled upon the notion that PNG images show up correctly in a VML fill element while working on DD_roundies. Thereafter, some Googling revealed that a few people had already known about this.
The intended implementation is pretty easy:
<!--[if IE 6]> <script src="DD_belatedPNG.js"></script> <script> /* EXAMPLE */ DD_belatedPNG.fix('.png_bg'); /* string argument can be any CSS selector */ /* .png_bg example is unnecessary */ /* change it to what suits you! */ </script> <![endif]-->
Due to popular demand, here is some documentation for how to “fix” elements on a pick-and-choose basis.
(Based on the normal usage approach)
This is intended solely for Internet Explorer 6. Use the script with conditional comments.
DD_belatedPNG is free software under the MIT License.
The License shall remain addressable at this URL: http://dillerdesign.com/experiment/DD_belatedPNG/#license
Copyright © 2008 Drew Diller
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
My thanks to Jonathan Snook for pointing out something else I had written was almost there for good PNG support.
Compressed 0.0.7a.js at 5.5Kb
Uncompressed 0.0.7a.js at 11Kb