Forum Moderators: open

Message Too Old, No Replies

Need the image to open up in a new window

         

dt24

3:27 am on Apr 25, 2009 (gmt 0)

10+ Year Member



My site shows an image of a product. The site resizes any image that I upload to it. I want this image to be clickable and open up in a new window to a larger size. Here is the current code that I see:

<td align="right" valign="top"><a href="#"><img src="include/sample1.php?nm=../product_images/<?=$image_path;?>&mwidth=268&mheight=376" border="0" /></a></td>

How can I alter this code?

rocknbil

2:46 pm on Apr 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard dt24.

Although the target attribute is deprecated, a simple solution is

<td align="right" valign="top"><a href="path_to/large_image.jpg" target="_blank"><img src="include/sample1.php?nm=../product_images/<?=$image_path;?>&mwidth=268&mheight=376" border="0" /></a></td>

As long as "target" does not exist in the document as an element name or id, it can be anything

target="new window"
target="dfsgdfgfg"

Alternatively, you can use Javascript's open() methods on the anchor. You would write a Javascript function that opens a new window, tailored to the size of the image, but be sure to return false from the Javascript function to the page doesn't navigate to the image. In this scenario, you would still leave the path to the large image in the anchor so if JS is disabled, it will still be accessible:

<a href="path_to/large_image.jpg" onClick="return my_javascript_window('path_to/large_image.jpg',600,400);" target="_blank">

dt24

2:36 am on Apr 26, 2009 (gmt 0)

10+ Year Member



Thanks a lot! Worked perfectly. Appreciate it.