-
Changing Bgcolor
I want a timer to change the bgcolor every second. So here is what I have so far:
<html>
<head>
<Body bgcolor = "Black">
<script type="text/javascript">
function start() {
var timeout = setTimeout("Timeout();",2000);
}
function Timeout() {
<Body BGcolor = "Red">
var timeout = setTimeout("Color2();",1000);
}
function Color2() {
<Body BGcolor = "Green">
var timeout = setTimeout("Color3();",1000);
}
function Color3() {
<Body Bgcolor = "Lime">
}
</script>
</head>
<body onLoad="start()">
</body>
</html>
-
Re: Changing Bgcolor
<script type="text/javascript">
function start() {
var timeout = setTimeout("Timeout();",2000);
}
function Timeout() {
document.bgcolor = 'red';
var timeout = setTimeout("Color2();",1000);
}
function Color2() {
document.bgcolor='green';
var timeout = setTimeout("Color3();",1000);
}
function Color3() {
document.bgcolor='lime';
}
</script>
-
I cant figure out was is wrong with this code. I put the code in notepad. And it doesnt do anything:
Code:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
<HTML>
<Body>
<script type="text/javascript">
function start() {
var timeout = setTimeout("Timeout();",2000);
}
function Timeout() {
document.bgcolor = "Red";
var timeout = setTimeout("Color2();",1000);
}
function Color2() {
document.bgcolor="green";
var timeout = setTimeout("Color3();",1000);
}
function Color3() {
document.bgcolor="lime";
}
</Body>
</script>
</HTML>
-
there isnt anything calling the first function called start.
Code:
<HTML>
<Body>
<script type="text/javascript">
function start() {
var timeout = setTimeout("Timeout();",2000);
}
function Timeout() {
document.bgcolor = "Red";
var timeout = setTimeout("Color2();",1000);
}
function Color2() {
document.bgcolor="green";
var timeout = setTimeout("Color3();",1000);
}
function Color3() {
document.bgcolor="lime";
}
start(); /*----that should start it off*/
</Body>
</script>
</HTML>
but your codfe will only change the colour threes times, if u want to loop it again you need to add stuff in to your functio Color3
-
It just sat there and didnt do anything. I have no clue what is wrong.
-
You're trying to run this from notepad????
Tell me I read that wrong. :confused:
-
I type the code into notepad. Then change the file extension to .html Then open it as a web document. I may be an idiot when it comes to HTML but im not that big of one.