Show multiple images in sequence

  • Thread starter Thread starter Paul Emmerich
  • Start date Start date
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top