SlideShow – Auto-Rotate

[Total: 0    Average: 0/5]

This shows how to have an HTML file use javascript to rotate through a selection of pictures at a rate of 1 picture per 5 seconds.

Body Code:

<table width=100%><tr><td align=center>
<script type=text/javascript>
var current = 0;
var myPics = new Array();
function addPic(_p) {
  myPics[myPics.length?myPics.length:0] = new Image();
  myPics[myPics.length-1].src=_p; // preload all pics


function checkIt(val) {
  current = Math.abs((current parseInt(val))%myPics.length);
  document.myimg.src = myPics[current].src;

document.write("<img name=myimg alt='' src='"+myPics[current].src+"'>");
var myTimer = setInterval('checkIt(1)',5000); // 5 second interval;


Times Viewed: 9

Leave a Reply

Your email address will not be published. Required fields are marked *