Image slider hlep |
Image slider hlep |
smtymagoo |
May 8 2012, 03:04 PM
Post
#1
|
Group: Members Posts: 3 Joined: 8-May 12 Member No.: 17,077 |
I have code for an image slider but I want to add a hyperlink to each image as it comes up. How would I do that with this code part of the code?
Thanks so much!! <script type="text/javascript"> <!-- var image1=new Image() image1.src="image1.jpg" var image2=new Image() image2.src="image2.jpg" <img src="http://image1.jpg" name="slide" height="400" width="940"> <script> <!-- //variable that will increment through the images var step=1 function slideit(){ //if browser does not support the image object, exit. if (!document.images) return document.images.slide.src=eval("image"+step+".src") if (step<3) step++ else step=1 //call function "slideit()" every 2.5 seconds setTimeout("slideit()",2500) } slideit() //--> </script> |
Christian J |
May 15 2012, 04:22 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,630 Joined: 10-August 06 Member No.: 7 |
Something like this then?
CODE <a href="" id="link"><img src="image1.jpg" id="slide" height="400" width="940"></a> <script type="text/javascript"> var url=['foo.html', 'bar.html']; // link URLs var pic=['dog.jpg', 'cat.jpg',]; // image URLs for(var i=0; i<pic.length; i++) { var preload=new Image(); preload.src=pic[i]; } var step=0; function slideit() { document.getElementById('link').href=url[step]; document.getElementById('slide').src=pic[step]; if(step<pic.length-1) { step++; } else { step=0; } setTimeout("slideit()",2500); // speed 2.5 seconds } slideit(); </script> |
Lo-Fi Version | Time is now: 28th March 2024 - 08:47 PM |