Setting Opacity in MSIE, Too
© 2011, Martin Rinehart
Code Today
Modern browsers, with one exception, use the standard CSS opacity
setting, a value between 0 (transparent) and 1 (opaque).
elem.style.opacity = opacity; // most modern browsers elem.style.filter = "alpha(opacity=" + (100*opacity) + ")"; // guess who
Old School
My library code is:
- more thorough, or
- obsolete but in a harmless way.
elem.style.opacity = opacity; // most modern browsers elem.style.MozOpacity = opacity; // original Mozilla elem.style.KhtmlOpacity = opacity; // older Konqueror, Safari elem.style.filter = "alpha(opacity=" + (100*opacity) + ")"; // guess who
I'm pretty sure MozOpacity
and KhtmlOpacity
are now gone, but the occasional reminder of what life was like in the "good old days" may still be appropriate. (Gray hair, by the by, does not come with age. It comes from stress.)
Feedback: MartinRinehart at gmail dot com
# # #