IE handles one of my div's classes totally wrong. It works in every other browser I tried. I want to simply not apply the class to the div in IE. Is there a trick to make IE not apply it?
More info: The div has multiple classes. I want to still load one but not the other in IE. The classes are defined in a Javascript file.
Thanks. Mike
IE handles one of my div's classes totally wrong. It works in every other browser I tried. I want to simply not apply the class to the div in IE. Is there a trick to make IE not apply it?
More info: The div has multiple classes. I want to still load one but not the other in IE. The classes are defined in a Javascript file.
Thanks. Mike
Share Improve this question edited Jun 28, 2009 at 23:11 Michael Swarts asked Jun 28, 2009 at 21:55 Michael SwartsMichael Swarts 5871 gold badge5 silver badges8 bronze badges3 Answers
Reset to default 6You can use conditional ments for IE to override the style on the class - that might be the easiest thing. Have a look here: MSDN link Essentially, you'd assign a more specific style to the class in the ment, overriding the standard - so, you could take most of the styling off. Intelligent browsers won't see the ment.
You can reset that specific style in a IE only stylesheet using something like this in the head section:
<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" media="screen" href="/styles/ie.css" />
<![endif]-->
(for IE 7 and below...)
Update to reflect some of the ments: You can target all non-IE browsers as a whole using this in your document (in the head if you go for styles):
<!--[if !IE]><!-->
/* some styles AND / OR javascript */
<!--<![endif]-->
I hate to do browser detection via javascript, but if none of the other solutions work you might try something like the following:
function removeClassForIE() {
// Look at userAgent to test for IE
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
var divs = document.getElementsByTagName("div");
for (var i = 0; i < divs.length; i++) {
if (divs[i].className == "myClassName") {
divs[i].className = "";
}
}
}
}
That should remove the class from those divs, and only if its IE. You could call the function like <body onload="removeClassForIE();">