vadivasbro@hotmail.com said:[color=blue]
>
>Very simple code. Why won't this work?[/color]
[color=blue]
>window.onload = document.getElementById("thisThing").style.backgro und =
>"red";[/color]
The first step in executing that assignment statement is to
evaluate the expression on the right hand side of the = sign.
Javascript will immediately squawk because there are two = signs
in that statement.
If that didn't cause a failure, the next thing it would do would
be to invoke the method:
document.getElementById("thisThing")
That's going to fail because the document hasn't been loaded yet
(we're still evaluating the value to be assigned to window.onload).
If that didn't fail, you still wouldn't really want to assign to
the window.onload attribute the value returned by the expression:
document.getElementById("thisThing).style.backgrou nd = "red";
because that value is not a Function reference. The value of
that expression is actually the string "red".
Try:
window.onload = function() {
document.getElementById("thisThing").style.backgro und = "red";
};