Forum Moderators: open

Message Too Old, No Replies

Swap Image and Swap Links

         

redefyned1

3:28 am on May 27, 2009 (gmt 0)

10+ Year Member



I have a site where I am using an image swap. When you mouse over a thumbnail, the larger image swaps out with the corresponding image.

What I would like to do is have the large image change URLs when the corresponding thumbnail is selected.

Is there a way to do this? I designed this site with Dreamweaver CS4 and use the Spry tools to make this happen. I have searched and searched but can not find a way.

Thanks in advance for any help I can get.

DrDoc

5:18 pm on May 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can easily do this in a similar fashion to your image swap:

<a href="/abc.html" id="myAnchorID"><img src="/images/t_abc.png" id="myImageID"></a>

And then, in your script:

arrImgs = new Array(2);
arrImgs[0] = new Image();
arrImgs[0].src = '/images/t_abc.png';
arrImgs[1] = new Image();
arrImgs[1].src = '/images/t_def.png';
arrHref = new Array(2);
arrHref[0] = '/abc.html';
arrHref[1] = '/def.html';
[...]
document.getElementById('myImageID').src = arrImgs[i].src;
document.getElementById('myAnchorID').href = arrHref[i];

You get the idea ...