Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2005
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    document.body.style.filter not working for firefox

    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

  • #2
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    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.)

    e.g.
    Code:
    function changeBG() {
    	var myBody = document.getElementsByTagName("body");
    	myBody[0].style.backgroundColor = "gray";
    }
    Code:
    <a href="#" onclick="changeBG(); return false;">Change background colour to gray</a>
    hth

  • #3
    New Coder
    Join Date
    Jun 2005
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi,

    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

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    document.getElementsByTagName("body")[0].style.color="gray";


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •