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

Thread: java slide show

  1. #1
    CJN
    CJN is offline
    New to the CF scene
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile java slide show

    Hello fellow forum members,
    Please, is someone willing to help me to (convert) this java script clickable slide show good for a automatic slide show as well?
    ------------------------------------------------------------------------
    <script language=javascript>

    for(var j = 0; j < imgAr1.length; j++)
    {
    rImg1[j] = new Image();
    rImg1[j].src = imgAr1[j];
    }

    document.onload = setting();

    var slide;
    function setting()
    {
    slide = document.getElementById('pic');
    slide.src = imgAr1[0];
    slide.setAttribute("width",width);
    slide.setAttribute("height",height);
    }

    //Image or picture slide show using java script
    //slideshow function
    var picture = 0;
    function slideshow(){
    if(picture < imgAr1.length-1){
    picture=picture+1;
    slide.src = imgAr1[picture];
    }
    }

    function prev(){
    if(picture > 0){
    picture=picture-1;
    slide.src = imgAr1[picture];
    }
    }

    function start(){
    slide.src = imgAr1[0];
    picture = 0;
    }

    function end(){
    slide.src = imgAr1[imgAr1.length-1];
    picture = imgAr1.length-1
    }
    </script>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    All you need is something like this:
    Code:
    setInterval( slideshow, 3000 ); // change pictures every 3 seconds
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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