Forum Moderators: open

Message Too Old, No Replies

Simple Image Slideshow Needed

don't want pages of code, just something dead simple!

         

HelenDev

9:35 am on Sep 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have an animated gif which is a bit photo heavy, so I thought maybe a really simple js slideshow would be the answer, but I can't fathom how to do it!

Basically I need...

//display image one for 2 secs
//replace with image two, display for 1.5 secs
//replace with image three, display for 6 secs
//loop forever!

Is this possible with js? All the scripts I have come across are reams and reams of code which do complicated stuff I don't want. I've also been playing around with some basic image swapping code snippets I found, none of which seem to work in Firefox! I need it to be cross browser.

Can anyone help?

sawatkins

3:47 pm on Sep 12, 2007 (gmt 0)

10+ Year Member



You should check Dynamic Drive (.com). I don't write Javascript, but I'm sure you'll find a simple useful script there for you.

Trace

3:58 pm on Sep 12, 2007 (gmt 0)

10+ Year Member



Quick and dirty but it should at least get you started;

<script type="text/javascript">
function playSlideShow(newImage){
document.getElementById('slideshow').src=newImage;
}
var cnt=0;
function allImages(){
switch(cnt){
case 0:
playSlideShow('images/menu_02.gif');
cnt++;
break;
case 1:
playSlideShow('images/menu_03.gif');
cnt++;
break;
case 2:
playSlideShow('images/menu_04.gif');
cnt=0;
break;
}
}
</script>

<img src="images/menu_01.gif" width="104" height="74" border="0" id="slideshow" alt="" />

<script type="text/javascript">
window.setInterval("allImages()", 3000);
</script>

HelenDev

2:47 pm on Sep 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Trace.

Got totally bogged down in other stuff now, but that looks a lot simpler than the other bits of code I've come across, and I'm sure will be handy.