Click to See Complete Forum and Search --> : Object Expected...grrr


SearedIce
07-05-2003, 10:30 PM
<html>
<head>
<script type="javascript">
function hexx()
{
document.body.bgcolor = document.a.b.value;
setTimeOut(1000, "hexx()");
}
</script>
</head>
<body onLoad="hexx()">
<form name="a">
<input name="b" type="textbox" value="000000">
</form>
</body>
</html>

How come this gives me an Object Expected error on line 11, the <body> line?

My IE has been giving me problems with all my javascripts lately...I've reset all defaults incase anything was accidentally changed but stuff still isn't working. One time the script would work when I had type="text/javascript" but with type="javascript" it would not...

~John

SearedIce
07-05-2003, 10:33 PM
<html>
<head>
<script type="text/javascript">
function hexx()
{
document.body.bgcolor = document.a.b.value;
setTimeOut(1000, "hexx()");
}
</script>
</head>
<body onLoad="hexx()">
<form name="a">
<input name="b" type="textbox" value="000000">
</form>
</body>
</html>

The above gives the Object Expected error on the setTimeOut line...

Jona
07-05-2003, 11:24 PM
Your setTimeout() method is backwards, and you have the "out" part capitalized:


setTimeout("hexx()", 1000);


[J]ona

SearedIce
07-06-2003, 11:01 AM
Oh ok...I always get setTimeout backwards...and I remembered it being with the out capitalized...oh well.

But now the script overall wont work...but its not giving me any errors at least...

What is the appropriate hierarchy for the background color. I'm thinking that "document.body.bgcolor" is not correct or otherwise my script should work...

SearedIce
07-06-2003, 11:03 AM
:) I forgot about css....document.body.style.background works fine!

Jona
07-06-2003, 02:25 PM
Originally posted by SearedIce
I'm thinking that "document.body.bgcolor" is not correct or otherwise my script should work...

Well, if you tested the script in NN4, it probably would have worked, unless the capitalization is wrong (it might have to be bgColor).

Anyways, the CSS solution is always the best one to go with, since CSS can be overridden by the user.

[J]ona