<head>
</head>
<body onload="setcolor()" >
<div id=mydiv style="font:12px sans-serif;width:300px;height:200px;">背景色测试</div>
<script>
function setcolor()
{
var colorString;
do{
colorString="#"+Math.floor(Math.random()*Math.pow(2,24)).toString(16);
}
while (colorString.length<7);
document.getElementById("mydiv").style.backgroundColor=colorString;
setTimeout(setcolor,100);
}
</script>
</body>