Script Categories













Background Effects >>> Color Wheel.

This JavaScript will change the background from one color to the next for each of the 10 colors then it starts the loop over again! There is also an On/Off button to let you start and stop the JavaScript.

Add the below code to the <BODY> section of your page:

<SCRIPT LANGUAGE="JavaScript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
var pos = 10;
var canGo=true;
function initArray() {
this.length = initArray.arguments.length;
for (var i = 0; i < this.length; i++) {
this[i] = initArray.arguments[i];
   }
}
var col=new initArray("4b","5b","8b","8b");
function Stop() {
document.bgColor = '#FFFFFF';
clearInterval(loopID);
canGo=true;
}
function Go() {
col[1]="red"
col[2]="yellowgreen"
col[3]="yellow"
col[4]="whitesmoke"
col[5]="white"
col[6]="wheat"
col[7]="violet"
col[8]="turquoise"
col[9]="tomato"
col[10]="thistle"
pos++;
if (pos<0||pos>10) {
pos = 0;
}
document.bgColor = col[pos];
//loopID = setTimeout("Start()",50);

}
function Start()
{
   if(canGo) loopID =setInterval("Go()",50);
    canGo=false;
}
window.onload=Start;
// End -->
</SCRIPT>
<FORM>
<input
type="button" value="On" onClick="Start()">
<input
type="button" value="Off" onClick="Stop()">
</FORM>
 

Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©