Monday, January 9, 2012

Change the background color in same page

***********************
write this code under head> tag
***********************
script type="text/javascript">
function init()
{
document.body.onclick = function()
{
colorChange();
}
function colorChange()
{
var colors = ["red","green","blue","orange","pink"];
var index = Math.floor(Math.random() * 100) % 5;
document.body.style.background = colors[index];
}
}
window.onload = init;
/script>