Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Ad Pro

macrumors member
Original poster
Jul 4, 2007
86
0
UK
Hi, i'm hoping this should be fairly simple but I've been trying to do it for a while now and cant seem to get it right. Any help would be much appreciated.

I have created a simple gallery with thumbnails down the right and the enlarged image on the left. The picture displayed changes when you mouse over the thumbnails. For the purpose of this it is just a cyan and magenta square. What i need to happen is when you click on the enlarged blue square it links to page 'a' and when you click on the enlarged magenta square it links to page 'b', I cannot get this to work.

I have included the html, css, and javascript file so please take a look.

thanks in advance for any help
 

Attachments

  • Gallery.zip
    45 KB · Views: 86
Think this is what you're after.

HTML
HTML:
  <div id="main">
    <div id="left">
    <a id="large" href="a.html"><img
    id ="largeimg" src="largeimage/1.jpg" width="340"/></a>   
    </div>
    <div id="right">
      <a href="thumb1.jpg" onmouseover="javascript:swapImage('1.jpg', 0); return false;"><img src="thumb1.jpg"/></a>
      <a href="thumb2.jpg" onmouseover="javascript:swapImage('2.jpg', 1); return false;"><img src="thumb2.jpg"/></a>
    </div>
    <div id="clear"><!-- --></div>
  </div>
JavaScript
Code:
var destinations = new Array('a.html', 'b.html');
function swapImage(image, x)
{
  document.getElementById('large').href = destinations[x];
  document.getElementById('largeimg').src = "largeimage/"+ image;
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.