#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    53
    Rep Power
    13

    slide shows in javascript


    i got this code from cnet to create a slideshow with javascript, is it possible to modify this code that when it reaches the last slide, instead of starting the show over, it moves on to another page??
    The code in action can be viewed here:
    http://builder.cnet.com/webbuilding/...upid/ss07.html


    Thanks for any help.

    PHP Code:
    <script language="JavaScript1.2">
    <!--
    // Cross-browser cleanup by Paul Anderson, CNET Builder.com. All rights reserved.
    var numSlides 5;
    var 
    currentSlide numSlides;
    // remove the next six lines if you don't want captions:
    var captionTxt = new Array(numSlides);
    captionTxt[1] = "Entrance to Pier 39"
    captionTxt[2] = "Sea lions lounging around the pier"
    captionTxt[3] = "Boats docked on the pier"
    captionTxt[4] = "Underwater World whale mural"
    captionTxt[5] = "Alcatraz, or The Rock"

    function setUp() {
    if (!
    document.all) {
       
    document.all document;
       for (
    i=1;i<=numSlides;i++) document.all[("image"+i)].style=document.all[("image"+i)];
       }
    switchSlide(1);
    }

    function 
    switchSlide(sDir) {
    newSlide currentSlide sDir;
    if (!
    newSlidenewSlide=numSlides;
    if (
    newSlide numSlidesnewSlide=1;
    document.all[("image"+newSlide)].style.visibility="visible";
    document.all[("image"+currentSlide)].style.visibility="hidden";
    // remove the next line if you don't want captions:
    document.all["captions"].document.forCaptions.captionsText.value=captionTxt[newSlide];
    currentSlide newSlide;
    }

    //-->
    </script> 
    here:http://builder.cnet.com/webbuilding/...upid/ss07.html
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Make
    Code:
    if (newSlide > numSlides) newSlide=1;
    Code:
    if (newSlide > numSlides) self.location.href = 'http://my.server/folder/new_page.html';
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    53
    Rep Power
    13
    I tried that and i get this error:

    document.all[...]style is null or not an object..this is line 28, the next line right after i added that code.
  6. #4
  7. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Try
    Code:
    if (newSlide > numSlides) {
      self.location.href = 'http://my.server/folder/new_page.html';
      return;
    }
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    53
    Rep Power
    13
    well that did get rid of the error, however, as soon as the slide show page loads, it redirects it to the new page already skipping the slide show. I appreciate your help though.
  10. #6
  11. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Change
    Code:
    var currentSlide = numSlides;
    to
    Code:
    var currentSlide = 1;
    Hehe. So much effort
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    53
    Rep Power
    13
    works great........thanks.......sorry its cause im not really that good with javascript............

IMN logo majestic logo threadwatch logo seochat tools logo