Help about set href option

Discussion in 'JavaScript' started by vesonet, Oct 17, 2010.

  1. #1
    Hi could you tell me how to set href link to every slide in this script:

    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>
    
    <script language="JavaScript">
    
    //Preloaded slideshow script- By Jason Moon
    //For this script and more
    //Visit http://www.dynamicdrive.com
    
    // PUT THE URL'S OF YOUR IMAGES INTO THIS ARRAY...
    var Slides = new Array('image1.gif','image2.gif','image3.gif');
    
    // DO NOT EDIT BELOW THIS LINE!
    function CacheImage(ImageSource) { // TURNS THE STRING INTO AN IMAGE OBJECT
       var ImageObject = new Image();
       ImageObject.src = ImageSource;
       return ImageObject;
    }
    
    function ShowSlide(Direction) {
       if (SlideReady) {
          NextSlide = CurrentSlide + Direction;
          // THIS WILL DISABLE THE BUTTONS (IE-ONLY)
          document.SlideShow.Previous.disabled = (NextSlide == 0);
          document.SlideShow.Next.disabled = (NextSlide == 
    (Slides.length-1));    
     if ((NextSlide >= 0) && (NextSlide < Slides.length)) {
                document.images['Screen'].src = Slides[NextSlide].src;
                CurrentSlide = NextSlide++;
                Message = 'Picture ' + (CurrentSlide+1) + ' of ' + 
    Slides.length;
                self.defaultStatus = Message;
                if (Direction == 1) CacheNextSlide();
          }
          return true;
       }
    }
    
    function Download() {
       if (Slides[NextSlide].complete) {
          SlideReady = true;
          self.defaultStatus = Message;
       }
       else setTimeout("Download()", 100); // CHECKS DOWNLOAD STATUS EVERY 100 MS
       return true;
    }
    
    function CacheNextSlide() {
       if ((NextSlide < Slides.length) && (typeof Slides[NextSlide] == 
    'string'))
    { // ONLY CACHES THE IMAGES ONCE
          SlideReady = false;
          self.defaultStatus = 'Downloading next picture...';
          Slides[NextSlide] = CacheImage(Slides[NextSlide]);
          Download();
       }
       return true;
    }
    
    function StartSlideShow() {
       CurrentSlide = -1;
       Slides[0] = CacheImage(Slides[0]);
       SlideReady = true;
       ShowSlide(1);
    }
    </script>
    </head>
    
    <body onLoad="StartSlideShow()">
    </body>
    
    <form name="SlideShow">
    <table>
    <tr>
       <td colspan=2><img name="Screen" width=108 height=135></td>
    </tr>
    <tr>
       <td><input type="button" name="Previous" 
    value=" << "
    onClick="ShowSlide(-1)"></td>
       <td align="right"><input type="button" name="Next"
    value=" >> " onClick="ShowSlide(1)"></td>
    </table>
    </form>
    
    </html>
    
    Code (markup):
    The links to be counted like this:
    "var Slides = new Array('image1.gif','image2.gif','image3.gif');"
     
    vesonet, Oct 17, 2010 IP
  2. _:codefan:_

    _:codefan:_ Active Member

    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    58
    #2
    
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>
    
    <script language="JavaScript">
    
    //Preloaded slideshow script- By Jason Moon
    //For this script and more
    //Visit http://www.dynamicdrive.com
    
    // PUT THE URL'S OF YOUR IMAGES INTO THIS ARRAY...
    var Slides = new Array('1.jpg','2.jpg','3.jpg');
    //Hrefs
    var Hrefs = new Array('http://google.com/', 'http://twitter.com/', 'http://facebook.com/');
    
    // DO NOT EDIT BELOW THIS LINE!
    function CacheImage(ImageSource) { // TURNS THE STRING INTO AN IMAGE OBJECT
       var ImageObject = new Image();
       ImageObject.src = ImageSource;
       return ImageObject;
    }
    
    function ShowSlide(Direction) {
       if (SlideReady) {
          NextSlide = CurrentSlide + Direction;
          // THIS WILL DISABLE THE BUTTONS (IE-ONLY)
          document.SlideShow.Previous.disabled = (NextSlide == 0);
          document.SlideShow.Next.disabled = (NextSlide == (Slides.length-1));    
    	
    	if ((NextSlide >= 0) && (NextSlide < Slides.length)) {
                document.images['Screen'].src = Slides[NextSlide].src;
    			document.getElementById('Screen_a').href = Hrefs[NextSlide];
                CurrentSlide = NextSlide++;
                Message = 'Picture ' + (CurrentSlide+1) + ' of ' + Slides.length;
                self.defaultStatus = Message;
                if (Direction == 1) CacheNextSlide();
        }
          return true;
       }
    }
    
    function Download() {
       if (Slides[NextSlide].complete) {
          SlideReady = true;
          self.defaultStatus = Message;
       }
       else setTimeout("Download()", 100); // CHECKS DOWNLOAD STATUS EVERY 100 MS
       return true;
    }
    
    function CacheNextSlide() {
       if ((NextSlide < Slides.length) && (typeof Slides[NextSlide] == 
    'string'))
    { // ONLY CACHES THE IMAGES ONCE
          SlideReady = false;
          self.defaultStatus = 'Downloading next picture...';
          Slides[NextSlide] = CacheImage(Slides[NextSlide]);
          Download();
       }
       return true;
    }
    
    function StartSlideShow() {
       CurrentSlide = -1;
       Slides[0] = CacheImage(Slides[0]);
       SlideReady = true;
       ShowSlide(1);
    }
    </script>
    </head>
    
    <body onLoad="StartSlideShow()">
    </body>
    
    <form name="SlideShow">
    <table>
    <tr>
       <td colspan=2><a id="Screen_a" href="#" target="_blank"><img name="Screen" width=108 height=135></a></td>
    </tr>
    <tr>
       <td><input type="button" name="Previous" 
    value=" << "
    onClick="ShowSlide(-1)"></td>
       <td align="right"><input type="button" name="Next"
    value=" >> " onClick="ShowSlide(1)"></td>
    </table>
    </form>
    
    </html>
    
    
    Code (markup):
     
    _:codefan:_, Oct 18, 2010 IP