mpalmer12345
Programmer
I want to do a simple alternation betwen black and white background colors. (I may expand it later to more colors, which explains the code below.) I would think the simple code below would work, but it doesn't! Why not?
Dec2Hex is a conversion function, obviously.
...
function changeBG(ii) {
bgR = (ii % 2) * 255;
bgG = (ii % 2) * 255;
bgB = (ii % 2) * 255;
bgRHex = Dec2Hex(bgR);
bgGHex = Dec2Hex(bgG);
bgBHex = Dec2Hex(bgB);
document.bgColor = bgRHex + bgGHex + bgBHex;
ii += 1;
setTimeout("changeBG(" + ii + ")", 1000);
}
//-->
</script>
</HEAD>
<BODY BGCOLOR=#FFFFFF onLoad="changeBG(0)">
</BODY>
</HTML>
Dec2Hex is a conversion function, obviously.
...
function changeBG(ii) {
bgR = (ii % 2) * 255;
bgG = (ii % 2) * 255;
bgB = (ii % 2) * 255;
bgRHex = Dec2Hex(bgR);
bgGHex = Dec2Hex(bgG);
bgBHex = Dec2Hex(bgB);
document.bgColor = bgRHex + bgGHex + bgBHex;
ii += 1;
setTimeout("changeBG(" + ii + ")", 1000);
}
//-->
</script>
</HEAD>
<BODY BGCOLOR=#FFFFFF onLoad="changeBG(0)">
</BODY>
</HTML>