Fix IE jQuery fading bug
September 25th, 2008
OK, so you fade some element in/out, and test in Firefox and it’s beautiful. Open IE, and, whoa, wait, what’s that split second of super ugly? Bold text, just before fading, gets all, chunky, and blotted, and pixelated, for lack of a better description. Here is my simple solution:
Say you start with
$("#someDiv").fadeOut();
after your event happens (click, focus, blur, whatever.)
Try it, put a bold line of text in a div, make a link, and give the link a click event that fades the div.
Try it, seriously, we’ll wait.
Did you see that? Annoying, right?
OK, add one more thing to that chain and it solves the ugly fade problem. Before fading: change the font color to match the background color. So if you have a background of #ccc and a font of #333 for example, your new chain would be
$("#someDiv").css("color", "cccccc").fadeOut();
and there you have it. NO, IT IS NOT PERFECT, but it’s much nicer looking than that mess you see without it. Of course, if you fade that guy back in, give his font the proper color again before he gets back, or the container will just look empty. My favorite thing about this “hack” is that it doesn’t change the look in Firefox (at least not with the default “speed” for fading.)




Posted on October 30, 2008
I have solved the problem in a more pleasant way: You have to add a CSS background-color rule (it can be the same bg-color than the page body, so you cannot notice it) to the element you are applying the fade effect. Try it.
Cheers.