Jump to content

[SOLVED] Image swap with changeable links


themistral

Recommended Posts

Hi all - I am a complete beginner when it comes to Javascript!

 

I have a list of thumnails which when clicked, show up as a bigger version on the page. This works great and this is the code I am using:

 

The main image where the swap is show on the webpage

$text .= '<img name="large" border="1" alt="product name" width="490" height="368" src="path/to/default/image" border="1" />';

 

The list of thumbnails

foreach ($files as $value) {
    $text .= '<img src="path/to/thumnail" border="0" width="70" height="53" onmousedown="document.images[\'large\'].src=\'path/to/image\'" />';
}

echo $text;

 

I now want to be able to click on the large image to open an even bigger version in a new window or tab.

 

Can anyone point me in the right direction please  ??? - I just keep finding lots of image swap stuff but nothing about changing a link as well.

Link to comment
https://forums.phpfreaks.com/topic/114057-solved-image-swap-with-changeable-links/
Share on other sites

add an onclick to the big image...like this:

$text .= '<img name="large" border="1" alt="product name" width="490" height="368" src="path/to/default/image" onclick="window.open(this.src,\'\',\'menubar=no,width=800,height=600,toolbar=no\');" border="1" />';

 

...change the 800x600 to whatever you want the size to be

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.