Jump to content
xisto Community

asdftheking

Members
  • Content Count

    82
  • Joined

  • Last visited


Reputation Activity

  1. Upvote
    asdftheking got a reaction from cityzen in Javascript Slideshow Tutorial How to make a slideshow in JavaScript   
    As soon as I set this up the first thing I did was make it autoplay, it just makes sense. If you haven't already figured it out or given up, here's how it goes:

    add two elements:

    object.style.display = 'none';

    // Show next picture, if last, loop back to front
    if (current == last) { current = 1; }
    else { current++ }
    object = document.getElementById('slide' + current);
    object.style.display = 'block';
    setTimeout(nextPicture, 2500); //NEW LINE in the end of nextPicture function
    } //a self repeating call at a delay of 2.5 secs
    //adjust the seconds to your liking


    linenums:0'>function nextPicture() { // Hide current picture object = document.getElementById('slide' + current); object.style.display = 'none'; // Show next picture, if last, loop back to front if (current == last) { current = 1; } else { current++ } object = document.getElementById('slide' + current); object.style.display = 'block'; setTimeout(nextPicture, 2500); //NEW LINE in the end of nextPicture function } //a self repeating call at a delay of 2.5 secs //adjust the seconds to your liking(the line which needs to be added should be 24.)

    then in line 79 change <body> to:
    (it will be 78 if you haven't already made the first change)

    <body onload="setTimeout(nextPicture, 2500);">
    I'm sure within a day or two I'll get bored with this and make the pictures fade in and out to black and/or white. I'll probably give a how to on that as well.
    Let me know if this works for you!
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.