Friday, April 15, 2011

Y10 - Javascript - Colour change code

<html>
<head>
<title>DISCO</title>
</head>

<body>
<script type="text/javascript">
window.onload = BG_change;
function BG_change()
{
document.body.style.backgroundColor = 'rgb(' +
Math.floor(Math.random() * 256) + ',' +
Math.floor(Math.random() * 256) + ',' +
Math.floor(Math.random() * 256) + ')' ;
setTimeout ( 'BG_change()', 100) ;
}
</script>
</body>
</html>

No comments:

Post a Comment