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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.