Show multiple images in sequence

P

Paul Emmerich

How do I show multiple images in sequence in one position on a web page? I
want several pictures to appear, one after the other, with something like a
two second delay on each picture. I don't even know what to call it much
less how to do it.

I assume that I need multiple images of exactly the same size to place one
after the other in sequence. Then change the link somehow every few
seconds.

I've seen this done on web sites but can't find an example right now (and
probably couldn't figure out the HTML if I did look at the source).

Paul
 
J

Jon

Hi Paul,
something like this
<script type="text/javascript">
img1 = new Image(); img1.src = "1st.jpg";
img2 = new Image(); img2.src = "2nd.jpg";
img3 = new Image(); img3.src = "3rd.jpg";
img4 = new Image(); img4.src = "4th.jpg";
// add as many images as you want
var howManyPics = 4; //set this to the number of pictures you have
var delay = 2; // set this to the number of seconds between each picture
//don't touch anything below here
var pic = 1;
function changePic(){
pic = (pic==howManyPics)?1:pic+1;
document.images['img'].src = eval('img'+pic+'.src');
}
</script>
</head>
<body onload="setInterval('changePic()', delay*1000);">
<img name="img" src="1st.jpg">

I'm calling this a slide show - you could call it something else if you like
:)

Jon
Microsoft MVP - FP
 
Top