Jump to content

href in slideshow


Matej
 Share

Recommended Posts

Hello ,i have slide show :

 

var i = 0; var path = new Array(); path[0] = "pic1.jpg" ; path[1] = "pic2.jpg"; path[2] = "pic3.jpg" ; function swapImage() { document.slide.src = path[i]; if(i < path.length - 1){ i++;} else {i = 0;} setTimeout("swapImage()",3000); } window.onload=swapImage;

 

how do i set href for each pic?Thanks for answers

Link to comment
Share on other sites

like this?

var i = 0; var path = new Array(); path[0] = "pic1.jpg" ; path[1] = "pic2.jpg"; path[2] = "pic3.jpg" ;  var change=new Array();change[0]="www.just.com";change[1]="www.some.com";change[2]="www.guy.com";function swapImage() { document.slide.src = path[i]; document.slide.href=change[i];if(i < path.length - 1&& i<change.length-1){ i++;} else {i = 0;} setTimeout("swapImage()",3000); } window.onload=swapImage;
Edited by Matej
Link to comment
Share on other sites

well yea it should be like

<a id="lol"><img src="davej.jpg" name="slide"></a>var i = 0; var path = new Array(); path[0] = "pic1.jpg" ; path[1] = "pic2.jpg"; path[2] = "pic3.jpg" ;  var change=new Array();change[0]="www.just.com";change[1]="www.some.com";change[2]="www.guy.com";function swapImage() { document.slide.src = path[i]; var m=document.getElementById("lol");m.setAttribute("href","change[i]");if(i < path.length - 1&& i<change.length-1){ i++;} else {i = 0;} setTimeout("swapImage()",3000); } window.onload=swapImage;

or? :D

Edited by Matej
Link to comment
Share on other sites

<a href="#"><img src="#" id="slide"></a><script>var i = 0; var path = []; path[0] = "pic1.jpg" ; path[1] = "pic2.jpg"; path[2] = "pic3.jpg" ;  var change=[];change[0]="www.just.com";change[1]="www.some.com";change[2]="www.guy.com";function swapImage() { var s=document.getElementById("slide");s.src = path[i]; s.parentNode.href = change[i];i++;if(i>=path.length || i>=change.length){i = 0;} setTimeout(swapImage,3000); } window.onload=swapImage;</script>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...