you should not use document.write, since it is executed when the page is being loaded, try
<head>
<script>
var next;
function aa() 
{
   next=new Array("black","yellow","white","pink","darkgreen")
}function start() 
{
  document.all("dv").innerHTML = next[nextshu];
  document.all("dv").style.backgroundColor = next[nextshu];
  ++nextshu;
  nextshu %= next.length;
}function ani() 
{
  setInterval("start()",500)
}function window.onload()
{
  nextshu=0
  aa()
  ani()
}</script>
</head>
<body>
<div id="dv"></div>
</body>