View Full Version : document.body.style.filter not working for firefox

06-02-2005, 09:12 AM
hi there,

in need to change the html page color as grey with the help of my javascript function. I am using "document.body.style.filter='grey'"; and this is working fine with IE. But it is not working with Firefox.

Please help me to find out the replacement for this command.

thank you guys

Bill Posters
06-02-2005, 10:17 AM
As you've probably worked out, the css filter attribute is MSIE5.5+ only.
There is a more appropriate attribute to use: background-color.

Here's an example of how to change the body element's background-color.
(Note that attributes with compound/hyphenated names are represented in javascript with the hyphen removed and the second word capitalised.)


function changeBG() {
var myBody = document.getElementsByTagName("body");
myBody[0].style.backgroundColor = "gray";

<a href="#" onclick="changeBG(); return false;">Change background colour to gray</a>


06-06-2005, 06:41 AM

i am not trying to make all the background color as grey. just i am trying to make the font color of the body content as grey.....

the code which i am working is fine with IE but it is not working with firefox....

please help me...

thank you in advance

06-06-2005, 03:59 PM