www.webdeveloper.com
Results 1 to 5 of 5

Thread: Adding a link to JS

  1. #1
    Join Date
    Dec 2011
    Posts
    12

    Adding a link to JS

    I would like to add a link my pictures. This is my code. As it is right now the slide show is broken when I put "document.images.SlideShow.src = preLoad[j].src;" in the code. When it's not in there it works great.

    Code:
    var imgArray = new Array(3); //this needs to be 15 in the end
    
    imgArray[0] = new Image;
    imgArray[0].src ="images/pic1.jpg";
    
    imgArray[1] = new Image;
    imgArray[1].src ="images/pic2.jpg";
    
    imgArray[2] = new Image;
    imgArray[2].src ="images/pic3.jpg";
    
    var linkArray = new Array();
    linkArray[0] = "contact.php";
    linkArray[1] = "elder.php";
    linkArray[2] = "about.php";
    
    var index = 0;
    
    function cycle()
    {
    	document.banner.src = imgArray[index].src;
    	 
    	index++;
    	if(index == 3)
    	{
    		index=0;
    	}
    	setTimeout("cycle()", 2000);
    	return;
    }
    Code:
    <body onLoad="cycle()">
    Code:
    <a href="citizenandcop.php"><img src="images/pic1.jpg" name="banner" alt="cycling pictures" width:100% height="80%"/></a>

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,636
    Code:
    function cycle()
    {
    document.banner.src = imgArray[index].src;
    document.banner.parentNode.href = linkArray[index];
    ...
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Dec 2011
    Posts
    12
    Works great!! The next part that I would like to do with it is have a total of 15 pics, where each set of three would go to the same page, but after three pictures the link would change.
    Last edited by Redbird5; 04-23-2013 at 03:28 PM.

  4. #4
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,636
    i don't see any problem about it. just do it the same way
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  5. #5
    Join Date
    Dec 2011
    Posts
    12
    Yep. I figured it out just after I wrote my last post.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles