Change background color of your web-page automatically


Posted on 2015-05-17 07:16:25


The following Javascript code will help you change the background-color of your web-page automatically and at a time-interval (in milli-seconds) as specified in the code.
<html> <head> <script type="text/javascript" language="javascript"> /* Method To Generate Random Numbers Between "0-255" for RGB Color-code Format & Assign To Body-Backgrond-Style */ function bgDisco() { var x =Math.round(255*Math.random()); var num1 =getHex(x); var y =Math.round(255*Math.random()); var num2 =getHex(y); var z =Math.round(255*Math.random()); var num3 =getHex(z); document.body.style.background="#"+num1+num2+num3; setTimeout("bgDisco()",1000); } </script> </head> <body onload="bgDisco()"> </html>