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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to make a slideshow stop

    I have a 20 image slideshow that keeps looping. I want it to stop after one cycle (i.e., after all 20 images have been showed once). Below is my code. What do I do, and where do I add it? Thanks!

    <head>
    <script type="text/javascript">
    var image1 = new Image()
    image1.src = "slide01.jpg"
    var image2 = new Image()
    image2.src = "slide02.jpg"
    var image3 = new Image()
    image3.src = "slide03.jpg"
    var image4 = new Image()
    image4.src = "slide04.jpg"
    var image5 = new Image()
    image5.src = "slide05.jpg"
    var image6 = new Image()
    image6.src = "slide06.jpg"
    var image7 = new Image()
    image7.src = "slide07.jpg"
    var image8 = new Image()
    image8.src = "slide08.jpg"
    var image9 = new Image()
    image9.src = "slide09.jpg"
    var image10 = new Image()
    image10.src = "slide10.jpg"
    var image11 = new Image()
    image11.src = "slide11.jpg"
    var image12 = new Image()
    image12.src = "slide12.jpg"
    var image13 = new Image()
    image13.src = "slide13.jpg"
    var image14 = new Image()
    image14.src = "slide14.jpg"
    var image15 = new Image()
    image15.src = "slide15.jpg"
    var image16 = new Image()
    image16.src = "slide16.jpg"
    var image17 = new Image()
    image17.src = "slide17.jpg"
    var image18 = new Image()
    image18.src = "slide18.jpg"
    var image19 = new Image()
    image19.src = "slide19.jpg"
    var image20 = new Image()
    image20.src = "slide20.jpg"
    </script>
    </head>
    <body>
    <p><img src="images/pentagg.jpg" width="1000" height="600" name="slide" /></p>
    <script type="text/javascript">
    var step=1;
    function slideit()
    {
    document.images.slide.src = eval("image"+step+".src");
    if(step<20)
    step++;
    else
    step=1;
    setTimeout("slideit()",500);
    }
    slideit();
    </script>
    </body>

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,899
    Thanks
    15
    Thanked 226 Times in 226 Posts
    Wow, what ancient code! Along with setTimeout you have clearTimeout, which stops the timeout. You can also use setInterval and clearInterval to make a slideshow. he w3 schools has a rundown on them.
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.


  •  

    Posting Permissions

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