Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 06-02-2005, 08:12 AM   PM User | #1
battasrinivasa
New Coder

 
Join Date: Jun 2005
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
battasrinivasa is an unknown quantity at this point
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
battasrinivasa is offline   Reply With Quote
Old 06-02-2005, 09:17 AM   PM User | #2
Bill Posters
Senior Coder

 
Join Date: Feb 2003
Posts: 1,665
Thanks: 0
Thanked 27 Times in 25 Posts
Bill Posters will become famous soon enough
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
Bill Posters is offline   Reply With Quote
Old 06-06-2005, 05:41 AM   PM User | #3
battasrinivasa
New Coder

 
Join Date: Jun 2005
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
battasrinivasa is an unknown quantity at this point
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
battasrinivasa is offline   Reply With Quote
Old 06-06-2005, 02:59 PM   PM User | #4
glenngv
Master Coder


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 9,877
Thanks: 0
Thanked 58 Times in 57 Posts
glenngv will become famous soon enough
document.getElementsByTagName("body")[0].style.color="gray";
__________________
Glenn
___________
Add JavaScript SameGame on Facebook and MySpace
Add JavaScript Tower of Hanoi game on Facebook and MySpace
glenngv is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:23 AM.

Home - Contact Us - Archives - Link to CF - Resources - Top 

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.