Afficher un message
Vieux 19/03/2008, 15h51   #6
Jukka K. Korpela
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Page background color won't change.

Scripsit test9991014@yahoo.com:

> The body tag has no id, nor can I set one.


So whose document are you playing with, and why?

> var foo = getelementbytagname("body")
> foo.style.background = "red"


When everything else fails, read the ******* manual. In this case, start
from a primer on JavaScript, preferably a mordern one which is based on
W3C DOMs.

This is simple sample code, just to prove that you need to actually
study JavaScript before trying to use it:

var body = document.getElementsByTagName("body")[0];
body.style.backgroundColor = "red";

Note that JavaScript is case sensitive (and typically uses camelCase for
identifiers).

Beware that this code needs to be placed so that when it is executed,
the document, including the body element, has been loaded and parsed.

Followups trimmed. This is about JavaScript and DOM, not CSS, so both
group choices were wrong, but alt.html (a catchall group) is less wrong.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

  Réponse avec citation
 
Page generated in 0,04677 seconds with 9 queries