Sunday, December 25, 2011

continuously change the background color by using loop

Example :  continuously change the background color by using loop

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Background effect by using loop </title>

<script language="javascript">

var COLOR = 999999
var woot = 0
function stoploop() {
document.bgColor = '#fff';
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)

<body style="width:800px; margin:0 auto">
<h3> continuously change the background color by using loop </h3>

<FORM NAME="background">
<INPUT TYPE="button" VALUE="Start bgColor WARP"
<input type="button" value="Stop bgColor WARP" onClick="stoploop()">



  1. This comment has been removed by the author.

  2. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Javascript Training in Chennai . or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry. ES6 Training in Chennai