0
4.2kviews
Write a JavaScript program to change background color continuously

Mumbai University > Information Technology > Sem 4 > Web Programming

Marks: 10M

Year: May 2014

1 Answer
0
7views

JavaScript program to change background color continuously:

<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title> Background effect by using loop </title>
<script language="javascript">
var COLOR = 999999
var woot = 0
function stoploop() 
{
document.bgColor = '#fff';
clearTimeout(loopID);
}
function loopBackground()
 {
if (COLOR > 0) 
{
document.bgColor = '#' + COLOR
COLOR -= 111111
loopID = setTimeout("loopBackground()",1)
}
else
{
document.bgColor = '#000000'
woot += 10
COLOR = 999999
COLOR -= woot
loopID = setTimeout("loopBackground()",1)
}
}
</script>

</head>
<body style="width:800px; margin:0 auto">
<center>
<h3> continuously change the background color by using loop </h3>
<FORM NAME="background">
<INPUT TYPE="button" VALUE="Start bgColor WARP"
onClick="loopBackground()">
<br>
<input type="button" value="Stop bgColor WARP" onClick="stoploop()">
</FORM>
</center>
</body>
</html>
Please log in to add an answer.