View Full Version : generating popup windows

07-14-2005, 01:28 PM
It's me again. Sorry if I'm being a pest, but I've got yet another script I can't get working. :rolleyes: That's what you get when art students embark on web design I guess...

Anyway, what I'm trying to do now is popup windows that show magnified images of thumbnails. Rather than code each popup into a different html document (there are almost 100 of them) I want to generate the popup code with javascript. I'm using the script found here (http://www.yourhtmlsource.com/javascript/popupwindows.html) as a guide.

And this (http://www.nightwings.net/test.html) is what I've done.

It just flat out doesn't work. But then again neither does the one on that other guy's site. Any ideas?

Thanks so much,

07-14-2005, 04:34 PM
Here are two problems, there could be others:

<a href="#" onClick="magnify(Barcelona,LC1);">Click</a>When passing literal strings to a function, they must be delimited by appropriate quotes, in this case, single quotes ('). Also when using a link tag in this fashion, it is wise to return false onclick to prevent possible undesirable effects, so that your link would look like this:

<a href="#" onClick="magnify('Barcelona', 'LC1');return false;">Click</a>

07-14-2005, 06:02 PM

Thanks for the help. I applied those changes. However, the code still doesn't work. Any other tips?


07-14-2005, 06:18 PM
I can't tell what the problem is as you haven't fixed the string literals problem on the page you linked to yet.

07-14-2005, 06:24 PM
I can't tell what the problem is as you haven't fixed the string literals problem on the page you linked to yet.

It's up now.

07-14-2005, 07:29 PM
Well, it is working, just not displaying your picture. Here is the picture it wants to display:

http://www.nightwings.net/actual/products/graphics/cabinet-doors/applied-moulding/LC1.jpgI suspect there is no picture by that exact name at that exact location. Remember, capitalization counts as much as exact spelling. Oh, and 'return false;' has a space between the two words, you have it 'returnfalse;' This has nothing to do with the picture not displaying but will become important later when your page is longer. Without return false properly included in the code, the link will cause the page to scroll to the top.

07-14-2005, 07:47 PM
the picture exists on my computer, I just didn't bother to upload it. I'm not worried about that part yet. I just need to get the popup working. It's strange that it shows up for you as nothing happens when I click the link.

I'm using Avant Browser/IE on Windows XP if that affects anything...

07-14-2005, 07:56 PM
Ok, I'm a dork. It doesn't show up in IE/Avant because I had my pop-up blocker on. Sorry. However, is there any way to get Netscape to open a window of the size I specify or is it always just a full sized window?

07-15-2005, 12:57 AM
Oddly enough, I have been working on a similar idea but, am using a different implementation. A demo exists at:


If you want to view the source code, be aware that it is an ad supported site so everything except the opening <html> tag before the opening <head> tag is put there by the server. The script uses two pages, one to create the new window and one to display the images within the new window. Because of this, it is not blocked by pop-up stoppers (not the default settings in the IE and NS7 ones at least) so much. It works in IE6 and NS7 and FF. It doesn't work in Safari/Mac, at least not in a test by another member of this forum. For what you are trying to do, you may be happier with:


from DD here. It uses a DHTML pop-up so it is not subject to blocking. It cannot render outside the browser window in the way that opening a new window can.

07-15-2005, 12:59 PM

Yes I saw a post about those other 2 methods yesterday. After seeing my script not work quite as planned yesterday, I was thinking I'd play around with those today. Thanks!