0% found this document useful (0 votes)
56 views2 pages

Change Background Color

The document describes a JavaScript program that uses setInterval to change the background color of a web page in a repeated manner by generating a random hex color code every 1000 milliseconds.

Uploaded by

Muskan agarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views2 pages

Change Background Color

The document describes a JavaScript program that uses setInterval to change the background color of a web page in a repeated manner by generating a random hex color code every 1000 milliseconds.

Uploaded by

Muskan agarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Muskan Agarwal

MCA (Section: A)
RollNo:55
Experiment
Objective – Design a Javascript program to change the
background color in repeated manner.
<!DOCTYPE html>
<html>
<head>
<title> background -color Change></background-colorCahnge></title>
</head>
<body>
<h1>background Experiment</h1>
<script>
setInterval(
function () {
var randomColor = Math.floor(Math.random()*16777215).toString(16);
document.body.style.backgroundColor = "#"+randomColor;
},1000);
</script>
</body>
</html>

Output:-

You might also like