...

View Full Version : help please to stop javascript slideshow



arjay
04-28-2012, 02:42 PM
Thanks to Old Pedant , in this forum, I am using this basic code for a slideshow he posted:


var slides = [
[ "abc.jpg", 3000 ],
[ "xyz.png", 5000 ],
[ "foo.gif", 1500 ]
];
var curSlide = 0;

function nextSlide( )
{
document.getElementById("thePicture").src = slides[curSlide][0].src;
setTimeout( nextSlide, slides[curSlide][1] );
curSlide = ( curSlide + 1 ) % slides.length;
}

function setUp( )
{
for ( var s = 0; s < slides.length; ++s )
{
var image = new Image();
image.src = slides[s];
slides[s] = image;
}
nextSlide( );
}

window.onload = setUp;

which works just fine. But I can't find a way for it to play one round of the slides then stop. Could someone please help me with the right bit of code to stop the show?

I know the code is a bit basic (no fades etc) but I have been unable to find a similar slideshow product that gives variable time delays for each slide. I've googled endlessly but nothing could i find....

TIA

Richard
=========

cryoffalcon
04-28-2012, 06:05 PM
Thanks to Old Pedant , in this forum, I am using this basic code for a slideshow he posted:


var slides = [
[ "abc.jpg", 3000 ],
[ "xyz.png", 5000 ],
[ "foo.gif", 1500 ]
];
var curSlide = 0;

function nextSlide( )
{
document.getElementById("thePicture").src = slides[curSlide][0].src;
setTimeout( nextSlide, slides[curSlide][1] );
curSlide = ( curSlide + 1 ) % slides.length;
}

function setUp( )
{
for ( var s = 0; s < slides.length; ++s )
{
var image = new Image();
image.src = slides[s];
slides[s] = image;
}
nextSlide( );
}

window.onload = setUp;

which works just fine. But I can't find a way for it to play one round of the slides then stop. Could someone please help me with the right bit of code to stop the show?

I know the code is a bit basic (no fades etc) but I have been unable to find a similar slideshow product that gives variable time delays for each slide. I've googled endlessly but nothing could i find....

TIA

Richard
=========

Why do you want it to stop after completion of one cycle, what is your purpose of using it?

arjay
04-28-2012, 07:02 PM
Why do you want it to stop after completion of one cycle, what is your purpose of using it?

Thanks for responding. I am working up a website for a local animal charity here in Spain, and they want a slideshow of five slides each with captions that make up a poem.

Once the poem is done the idea is that it then stops - on the last frame. I think that's a good idea (it is distracting enough as it is IMO but the client is the client....)

Any ideas what I can add to the code to do this?

Ta

arjay
04-29-2012, 10:00 PM
Never mind - found a solution. Had to buy a commercial product. That's fine but I don't have a windows PC (only run Linux on my boxes) so had to set up a virtualbox with an old copy of XP just to be able to use it. Doesn't seem to be any linux equivalent...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum