1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
<html>
<head>
<title></title>
<script type="text/javascript">
<!--
var couleurs = new Array("#AAAAAA","#F0F8FF","#8A2BE2","#4B0082","#FF0000","#0000FF","#2E8B57","#9ACD32");
function randomColor()
{
var n = couleurs.length;
var c;
c = Math.round(Math.random()*n);
document.getElementById("div1").style.backgroundColor = couleurs[c];
c = Math.round(Math.random()*n);
document.getElementById("div2").style.backgroundColor = couleurs[c];
c = Math.round(Math.random()*n);
document.getElementById("div3").style.backgroundColor = couleurs[c];
c = Math.round(Math.random()*n);
document.getElementById("div4").style.backgroundColor = couleurs[c];
}
//-->
</script>
</head>
<body onload="randomColor()">
<div style="height: 100px;width: 100px" id="div1">div 1 </div>
<div style="height: 100px;width: 100px" id="div2">div 2 </div>
<div style="height: 100px;width: 100px" id="div3">div 3 </div>
<div style="height: 100px;width: 100px" id="div4">div 4 </div>
</body>
</html> |
Partager