Forum Moderators: open

Message Too Old, No Replies

Adding Links to Slideshow

         

fjohnson

7:46 pm on Sep 29, 2008 (gmt 0)

10+ Year Member



Hi,
I have this js slidehow running on my site and I want to add links to each image. I'm sure it is not to difficult, but I do not know a lot about js, so any help would be appreciated. Slideshow is as follows:

.js file
------------------------------
<!-- Begin
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 4000;
// Duration of crossfade (seconds)
var crossFadeDuration = 8;
// Specify the image files
var Img = new Array();
// to add more images, just continue
// the pattern, adding to the array below

Img[0] = 'http://www.site.com/images/main1.jpg'
Img[1] = 'http://www.site.com/images/main2.jpg'
Img[2] = 'http://www.site.com/images/main2.jpg'

// do not edit anything below this line
var t;
var j = 0;
var p = Img.length;
var preLoad = new Array();
for (i = 0; i < p; i++) {
preLoad[i] = new Image();
preLoad[i].src = Img[i];
}
function runSlideShow() {
if (document.all) {
document.images.SlideShow.style.filter="blendTrans(duration=2)";
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply();
}
document.images.SlideShow.src = preLoad[j].src;
if (document.all) {
document.images.SlideShow.filters.blendTrans.Play();
}
j = j + 1;
if (j > (p - 1)) j = 0;
t = setTimeout('runSlideShow()', slideShowSpeed);
}
// End -->

-------------------------------

in <body>:
onLoad="runSlideShow()"

---------------------------------
in HTML:
<img src="http://www.site.com/images/main1.jpg" name='SlideShow' width="400" height="300" title="site />

---------------------------------

Thank you so much for your help :)

grallis

3:22 am on Sep 30, 2008 (gmt 0)

10+ Year Member



Where are you trying to add the links? Are you trying to link into the slideshow, or link from the slideshow you somewhere else?

fjohnson

12:37 pm on Sep 30, 2008 (gmt 0)

10+ Year Member



I want to add the links to each image...from the slideshow to another page. Thanks!

astupidname

6:19 pm on Sep 30, 2008 (gmt 0)

10+ Year Member



Immediately after the Img array in the script add another array to hold your links to use:
var links = new Array();
links[0] = 'page1.html';
links[1] = 'page2.html';
links[2] = 'page3.html';

And then in the function immediately after the line that reads "document.images.SlideShow.src = preLoad[j].src;" Add this line after that:
document.getElementById("changeable").href = links[j];

Then in the body of the html, wrap the default image in a set of anchor tags with an id in them:
<a href="defaultpage.html" id="changeable"><img src="http://www.site.com/images/main1.jpg" name="SlideShow" width="400" height="300" alt="picture" title="site" /></a>

You may be aware that the crossfade in that script only works in IE. You could do some research also there are slideshows out there that have crossfades that work in FF and others also.

fjohnson

2:39 pm on Oct 1, 2008 (gmt 0)

10+ Year Member



Thank you so much! Works perfectly!