November 3, 2010

While refreshing different color changing

Use this javascript:

var color=new Array(7);
color[0]="#246fcf";
color[1]="#0e9eb8";
color[2]="#0eb8b2";

function changeColor()
{
var ranNum= Math.floor(Math.random()*7);
document.getElementById('div1').style.backgroundColor=color[ranNum];
}


and use this onload function in the body tag

'[body onload="changeColor()"]'


eg:

[div id="div1" name="div1" style="height:5px;"][/div]

No comments:

Post a Comment