Skrypt pozwala samoczynnie wyświetlać sekwencję grafik. Opiera się na kodzie zawartym w HEAD, BODY onload i tabeli zawierającej wyświetlane obrazki.
W skrypcie zwróć uwagę na definicje obrazków (Pic[0],...), częstotliwość wyświetlania w milisekundach (varspeed), rozmiary tabeli i pierwszego obrazka z sekwencji
Skopiuj przykładowy kod
W ramach HEAD
<script> // (C) 2000 www.CodeLifter.com // http://www.codelifter.com // Free for all users, but leave in this header // ======================================= // set the following variables // ======================================= // Set speed (milliseconds) var speed = 3000 // Specify the image files var Pic = new Array() // don't touch this // to add more images, just continue // the pattern, adding to the array below Pic[0] = '../grafika/ami.gif' Pic[1] = '../grafika/pcq.gif' Pic[2] = '../grafika/enter.gif' // ======================================= // do not edit anything below this line // ======================================= var t var j = 0 var p = Pic.length var preLoad = new Array() for (i = 0; i < p; i++){ preLoad[i] = new Image() preLoad[i].src = Pic[i] } function runSlideShow(){ document.images.SlideShow.src = preLoad[j].src j = j + 1 if (j > (p-1)) j=0 t = setTimeout('runSlideShow()', speed) } </script>
Definicja BODY
<body onload="runSlideShow()">
W ramach BODY
<table border="0" cellpadding="0" cellspacing="0"> <tr> <td id="VU" height=80 width=114> <img src="../grafika/ami.gif" name='SlideShow' width=80 height=114></td> </tr> </table>