I'm trying to use JavaScript to remove the CSS attribute "filter" from a block of text on a page.
The reason is that using filter disables ClearType in IE8.
I've tried using document.getElementById("someDiv").style.removeAttribute('filter');
and someDiv.style.removeAttribute('filter');
which don't throw errors, but have no effect.
Any suggestions would be appreciated.
Thanks for reading,
Louis
Here's an example page:
http://img37.imageshack.us/img37/9057/filteroff.png
Filter off.
http://img203.imageshack.us/img203/3821/filteron.png
Filter on.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example</title>
</head>
<body style="filter:progid:DXImageTransform.Microsoft.Gradient(endColorstr='#ffffff', startColorstr='#eeeeee', gradientType='0');">
<div id="SomeText">
Hi, I'm some text.<br />
How's ClearType handling me?
</div>
<script type="text/javascript">
document.getElementById("SomeText").style.removeAttribute('filter');
SomeText.style.removeAttribute('filter');
</script>
</body>
</html>
Probably can't remove filter from the
<div>
because it has no filter property.<body>
is the tag with the property; after some messing arounddocument.body.style.filter = '';
Removes the filter (but obviously, from the whole body).