Click to See Complete Forum and Search --> : color looping
Cow_DestroyerX
05-07-2003, 01:02 PM
:confused:im trying to make a page that loops bgcolor but it doesn't want to work
its at geocities.com/sir_unholyness/Looping.html (http://www.geocities.com/sir_unholyness/Looping.html):confused:
Not sure if you want it to keep going or not, but this works:
<html>
<head>
<title>Looping</title>
<script language="Javascript">
colors = new Array (9);
colors[0] = "#f0f0f0";
colors[1] = "#ff0000";
colors[2] = "#00ff00";
colors[3] = "#0000ff";
colors[4] = "#ffff00";
colors[5] = "#ff00ff";
colors[6] = "#00ffff";
colors[7] = "#ffffff";
colors[8] = "#ff0099";
for(i=0;i<colors.length;i++)
document.bgColor=colors[i];
</script>
</head>
<body>
</body>
</html>
JackTheTripper
05-07-2003, 02:35 PM
Your line...
document.bgcolor = colors[i]
should read...
document.bgColor = colors[i]
Sux that such a minor mistake will screw with you, huh? I hate that.
Just remember, JavaScript is case-sensetive. ;)
Cow_DestroyerX
05-08-2003, 12:33 PM
it doesn't work for some reason
my teacher has been teaching this class for 2 years now and he has yet to get it to work
I don't know what you have this for, but:
for (j="0; j<1000; j++);{}
should be:
for (j=0; j<1000; j++);{}
Cow_DestroyerX
05-08-2003, 12:39 PM
ok now it uses the color but only the last 1, how do i get it to loop through the colors continuosly but with like 5 seconds in between colors
<html>
<head>
<title>Looping</title>
<script language="Javascript">
colors = new Array (9);
colors[0] = "#f0f0f0";
colors[1] = "#ff0000";
colors[2] = "#00ff00";
colors[3] = "#0000ff";
colors[4] = "#ffff00";
colors[5] = "#ff00ff";
colors[6] = "#00ffff";
colors[7] = "#ffffff";
colors[8] = "#ff0099";
function chng_bg(){
for(i=0;i<colors.length;i++)
document.bgColor=colors[i];
}
setInterval("chng_bg()", 10);
</script>
</head>
<body>
</body>
</html>
Cow_DestroyerX
05-08-2003, 12:52 PM
it changes directly from white to pink with a 1 second delay but i want it to use all 9 colors not just the last 1. do u know how to do that?
Cow_DestroyerX
05-08-2003, 12:57 PM
ive giving it up for now so thanks for your help