Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help please to stop javascript slideshow

    Thanks to Old Pedant , in this forum, I am using this basic code for a slideshow he posted:

    Code:
    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
    =========

  • #2
    Regular Coder
    Join Date
    Oct 2010
    Posts
    157
    Thanks
    2
    Thanked 1 Time in 1 Post
    Quote Originally Posted by arjay View Post
    Thanks to Old Pedant , in this forum, I am using this basic code for a slideshow he posted:

    Code:
    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?

  • #3
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by cryoffalcon View Post
    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

  • #4
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •