Can anyone convert this little script to continuously change the background of a DIV, instead of the background of the page?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<body>
<script language="JavaScript">
<!--
// please keep these lines on when you copy the source
// made by: Nicolas - [URL unfurl="true"]http://www.javascript-page.com[/URL]
var currentcolor = 0
function initArray(n) {
this.length = n;
for (var i =1; i <= n; i++) {
this[i] = ' '
}
}
bgcolors = new initArray(15)
bgcolors[0]="ffffff"
bgcolors[1]="ffdead"
bgcolors[2]="ffffff"
bgcolors[3]="add8e6"
bgcolors[4]="0000ff"
bgcolors[5]="add8e6"
bgcolors[6]="90ee90"
bgcolors[7]="00ff00"
bgcolors[8]="90ee90"
bgcolors[9]="ffc0cb"
bgcolors[10]="ff0000"
bgcolors[11]="ffc0cb"
bgcolors[12]="FFFFFF"
bgcolors[13]="ffdead"
bgcolors[14]="FFFFFF"
function backgroundChanger() {
[COLOR=red]document.getElementById("test").bgcolor[/color] = bgcolors[currentcolor];
if (currentcolor < bgcolors.length-1) {
currentcolor++
setTimeout("backgroundChanger()", 1000);
}
}
backgroundChanger();
//-->
</script>
<div id="test" style="width: 400px; height: 200px"></div>
</body>