View Full Version : Link within a link

08-03-2011, 06:59 PM
Hey everyone :)

It's really hard to explain this so I need to show you... Ignore most of the code in this page but hit ctrl f and type "images/cinema_display.jpg" and you should get to the exact part :)


If you actually go onto the page, what I am trying to do is when you click that cinema display a larger one is shown to the right, I want that larger image on the right to then link to another page. I want it to be unique for every image, though. Is this possible?

Thanks for any responses, all appreciated :p

Owen Ayres

08-03-2011, 09:03 PM
Yes, you can do some javascript to get that to work as intended. I would alter your code a bit before doing that though. The thumbnail link should probably be set up to be the actual item page rather than the image source for the item's large image. That way if a user has javascript disabled they can still get to the product review. Then you can have javascript update the main image with a link to the review by the same method you currently have the image source being changed.

That would leave you with the issue of getting the right image source over to the main image, which could be done a number of ways. If your file naming convention is static you could simply check the image source of the image within the link that triggers the javascript and then remove the "_thumb" portion of the name and that would send you to the correct fullsize image.

On the other hand, if naming is not always so predictable, you could store the full-size image's URL in the "rel" attribute of the anchor tag and access that through javascript just as you would do for the "href" attribute.

I'm not sure if I'm explaining that clearly, but it makes perfect sense in my head! :thumbsup:

08-03-2011, 09:13 PM
Thanks for the reply!

It makes a bit of sense to me, but there is one major issue: I'm a newbie in Javascript haha.
No worries anyway though, I've decided to switch to a simpler method because I will be updating this regularly and so wish to keep it clean and easy to understand for myself!

Again, thanks for the effort made to respond though! :)

Owen Ayres