JavaScript Programming
JavaScript > Code Examples
4-Flasher Background Color Effect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
4-Flasher Background Color Effect
<script language="JavaScript">
<!--
var backColor = new Array(); // don't change this
// Set the speed (in milliseconds).
var dwellTime = 500;
// Enter the colors you wish to use. The final
// backColor[4] should be the fixed color of the
// page.
backColor[0] = '#FF0000';
backColor[1] = '#008000';
backColor[2] = '#000099';
backColor[3] = '#000000';
backColor[4] = '#FFFFFF';
// Do not edit below this line.
//-----------------------------
function flashBG(whichColor){
document.bgColor = backColor[whichColor];
}
var t = null;
var d = dwellTime;
t = setTimeout('flashBG(0)',(d-d));
t = setTimeout('flashBG(1)',(d));
t = setTimeout('flashBG(2)',(d*2));
t = setTimeout('flashBG(3)',(d*3));
t = setTimeout('flashBG(4)',(d*4));
t = null;
//-->
</script>