Funkční příklad, stačí doplnit obrázky a cesty:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Rotace obrázků</title>
<script type="text/javascript" language="javascript">
<!--
doba=5000
pocet = 4
rotator=0
obrsrc = new Array(pocet)
cesta =new Array(pocet)
obrsrc[0]="rotator_soubory/img1.gif"; cesta[0]="http://www.cosi.cz/?stranka=detailclanku& id=266";
obrsrc[1]="rotator_soubory/img2.jpg"; cesta[1]="http://www.cosi.cz/?stranka=detailclanku& id=266";
obrsrc[2]="rotator_soubory/img3.jpg"; cesta[2]="http://www.cosi.cz/?stranka=detailclanku& id=266";
obrsrc[3]="rotator_soubory/img4.png"; cesta[3]="http://www.cosi.cz/?stranka=detailclanku& id=266";
obr = new Array(pocet);
for (i=0; i < pocet; i++){
obr[i]= new Image();
obr[i].src= obrsrc[i]
}
function rotate() {
if (rotator==pocet) {rotator=0;}
document.images["obraz"].src = obrsrc[rotator];
rotator = rotator + 1
window.setTimeout('rotate();',doba);
}
function poslat() {
window.location=cesta[rotator-1];
return false;
}
//--></script>
</head>
<body onload="rotate();">
<a href="/rotator_soubory/moskva.jpg" onclick="return poslat();">
<img name="obraz" src="rotator_soubory/moskva.jpg" alt="" width="570" height="260" /></a>
</body>
</html>