#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    2
    Rep Power
    0

    javascript slideshow end


    Hello,
    I'd like to end this auto image slide show after 3 times but am not sure how to go about this. It currenlty continues to loop.

    Here's the code.

    <script>
    var slideShowSpeed = 5000
    var crossFadeDuration = 3
    var Pic = new Array()
    Pic[0] = '1.jpg'
    Pic[1] = '2.jpg'

    var t
    var j = 0
    var p = Pic.length

    var preLoad = new Array()
    for (i = 0; i < p; i++){
    preLoad[i] = new Image()
    preLoad[i].src = Pic[i]
    }

    function runSlideShow(){
    if (document.all){
    document.images.SlideShow.style.filter="blendTrans(duration=2)"
    document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
    document.images.SlideShow.filters.blendTrans.Apply()
    }
    document.images.SlideShow.src = preLoad[j].src
    if (document.all){
    document.images.SlideShow.filters.blendTrans.Play()
    }
    j = j + 1
    if (j > (p-1)) j=0
    t = setTimeout('runSlideShow()', slideShowSpeed)
    }
    </script>

    ----the body requires this <body onload="runSlideShow()">

    Thanks,
    Matt


    ps. code from // (C) 2000 www.CodeLifter.com
    // http://www.codelifter.com
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Amsterdam
    Posts
    7
    Rep Power
    0
    Just set a global var times and do something like this:

    var TIMES = 3;

    document.images.SlideShow.src = preLoad[j%p].src
    if (j > (p*TIMES))
    clearTimeOut(t);
    else
    j++;

    This could work...I think
    Last edited by quasi; March 17th, 2003 at 07:33 AM.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    2
    Rep Power
    0
    Thanks for responding. I tried it but it did not work.

    Thx again!

IMN logo majestic logo threadwatch logo seochat tools logo