View Full Version : Open popup template with called image

01-18-2006, 12:26 AM
Hey there,

I've searched around to try and find a similar question but only found bits and pieces (which did help). I hope this is the correct forum for this post.

I have many product pages with product thumbnail images. The images are in one directory and enlargements of these images are in another called 'popup'. On my product page I would like to click on the product thumbnail and have a popup window open with the enlarged image of that product from the popup directory. The catch is that I have a template popup window that I would like to use each time. I have gotten this formatted the way I would like it, I just need some way of inserting the enlarged image in popup window.

I was wondering if a script in place of a src<""> image directory would work. I'm not sure if if this is something I need on the product page itself or if the code will reside in the popup template. Basically, this is a way around making a separate html popup window for each product...of which there are a lot!

Any thoughs or insight would be greatly appreciated. Let me know if I should provide any of the code I have so far. Thanks!!!


01-18-2006, 02:55 AM
Do you have access to a server-side language? It would be simple to do if you had, say ASP, PHP, or CGI.

01-18-2006, 04:23 PM
2reikis - Yes, I have access to many since this site is on a dedicated server. Most of the other scripts in the site are done with Perl. It would be great to be able to use that. However, someone else is doing the Perl coding and I am not familiar with it. I am just learning PHP, so have a small amount of fimiliarity with server side languages.

01-23-2006, 04:14 PM
Just thought I'd add something else. Suggestions from the Perl coder are:

If the pop-up directory is called popup, then the javasript would be called like so:


Now, the problem that is left is how to pass that string to the doPopup function. If we wrote the Javascript in-line on the page, our Perl code could simply write the call and insert the proper text string. However, I know that we've so far kept Javascript totally out of the HTML and probably want to continue doing so.

We could add an attribute to the product image that contains the pop-up image string. Then, your Javascript could extract that attribute at run-time and use it to load the pop-up.

Just wondered it this helps.

01-24-2006, 01:13 AM
Actually, there is a way to do this in Javascript. I've modified this script from a gallery I did.

<script language="javascript" type="text/javascript">
// Global variable to keep track of how many popups are open
var numWinOpen
// open a window and write the html
function fnImageOnClick(ndx)
var opt=new String()
var strTemp, strTemp2
// set options for window
var numWidth=250
// limit number of picture windows open
if (++numWinOpen>=6) numWinOpen=1
// make sure it's not open already. Otherwise focus might not be passed
if ((picWin[numWinOpen])&&(!picWin[numWinOpen].closed)) picWin[numWinOpen].close()
// open window, insert HTML
picWin[numWinOpen]=window.open("", strTemp2, opt)
with (picWin[numWinOpen])
document.write("<IMG SRC='"+strTemp+"'>")

And then for the thumbnail

<a href="javascript:fnImageOnClick('image1.gif')"><img src="images/image1_thumb.gif" border=0></a>

Does that do ya?