<head>
<meta charset="utf-8">
</head>
<body>
<div id="id" style="display: block; width: 200px; height: 200px; border: 1px solid grey;"></div>
<script>
var rand2;
document.getElementById("id").onmouseover = function(){
var color = ['red','green','blue','orange','yellow','violet','cyan'];
var rand;
do {
rand = Math.floor(Math.random() * color.length);
this.style.backgroundColor = color[rand];
} while (rand == rand2);
rand2 = rand;
};
</script>
</body>
Ну теперь то идеально?