Javascript slide show

Discussion in 'JavaScript' started by richjarvis, Jan 15, 2007.

  1. #1
    I have created a javascript slideshow using the following code

    <SCRIPT language="javascript" src="http://www.testreg7.co.uk/auto/script.js"></SCRIPT>
    <SCRIPT LANGUAGE="JavaScript">
    var images = new Array (
    "image1.jpg",
    "image2.jpg",
    "image3.jpg",
    "image4.jpg"
    );
    /*var msg_url = new Array(
    "test.html",
    "http://www.ASPNews.com",
    "http://www.cnn.com" );*/
    var iNum = 0;
    var imagesLength = images.length - 1;
    </SCRIPT>

    (script.js)

    function change(image) {
    if (document.images) {
    iNum = iNum + image;
    if (iNum > imagesLength) {
    iNum = 0;
    }
    if (iNum < 0) {
    iNum = imagesLength;
    }
    document.slideshow.src = images[iNum];
    }
    }
    function manchange(image){
    document.slideshow.src = images[image];
    iNum = image;
    }


    function goURL(){

    location.href=msg_url[iNum];

    }

    What I need to know is whether or not it is possible to link each photo within the slideshow to different pages, and if so how this would be done. thank you in advance
     
    richjarvis, Jan 15, 2007 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    you would have either another array or a two-dimensional array. both arrays would use the same index variable (iNum) and you could define a url for each item then.
     
    ccoonen, Jan 15, 2007 IP
  3. richjarvis

    richjarvis Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If any would could give an example of how to do this it would be greatly appreciated as i a just learning javascript so my knowledge is fairly limited
     
    richjarvis, Jan 16, 2007 IP