<script language=javascript> n=3; // Number of links alink=new Array(); // Array of links alink[1]="<a href=http://www.yahoo.ru>Yahoo</a>"; // Assign references alink[2]="<a href=http://www.av.com>Alta Vista</a>"; alink[3]="<a href=http://www.100hot.com>100 Hot</a>"; r=new Array(); l=new Array(); for(i=1;i<=n;i++) r[i]=Math.random(); // Random number for each reference for(j=1;j<=n;j++) { k=2; for(i=1;i<=n;i++) if(k>r[i]) {l[j]=i; k=r[i];} // Find least number r[l[j]]=3; // Exclude this (l[j]-th) reference from further considering } </script> ... /* Write references in turn*/ <script language=javascript> for(i=1;i<=n;i++) document.write(alink[l[i]],"<br>"); </script>See result