PDA

View Full Version : Simple Image Gallery PopUp using Javascript



eastboy301
03-12-2007, 03:51 PM
I have an image gallery of thumbnails in an html page. I want it so that you can click on these thumbnails and it will open up the original bigger picture inside an HTML file in a new window using javascript coding.

I also need to make it so that each photo opens in a new window using the SAME html page. I think they are called URL variables or something of that sort. for instance if I have a picture with the filename pick001.jpg I want it so that when you click on its thumbnail it opens up in a URL like "photo.html?=pick001.jpg".

One more requirement is for each of the popups to open in the SAME window. I dont want multiple new windows opening each time the user clicks on a thumbnail.

Can anybody help me with this?

rajug
03-13-2007, 04:48 AM
Which server side scripting language are you using your page. If you can tell me that i would help you. so lease be more descriptive.

jscheuer1
03-13-2007, 05:09 AM
Actually, that can be done all on the client side. Your page could even be generated as part of the pop up function. Here is an example:

http://www.mediajazzbynight.com/2006/gallery.htm

View the source to see the script code, it is the one with this credit:


Auto center window script- Eric King

rajug
03-13-2007, 05:49 AM
Thank you jscheuer1. I also learned something from that link that without any file we can get pop up too.

eastboy301
03-13-2007, 02:33 PM
Actually, that can be done all on the client side. Your page could even be generated as part of the pop up function. Here is an example:

http://www.mediajazzbynight.com/2006/gallery.htm

View the source to see the script code, it is the one with this credit:


Auto center window script- Eric King

can't thank you enough man, this is very useful.

i'm loading the new window from a flash movie though. Will I be able to do that with this script?

jscheuer1
03-13-2007, 04:37 PM
can't thank you enough man, this is very useful.

i'm loading the new window from a flash movie though. Will I be able to do that with this script?

Probably not by using the usual Action Script syntax for loading a new window. However, I believe there is a way to run javascript from Flash. That would be the way to go but, it may be blocked by a pop up blocker.

If you can put a link into the Action Script and have its href be like:


<a href="javascript:NewWindow('image.jpg','amigos','676','397','no', 'Ellas y Amigos')">whatever</a>

Thats:


javascript:NewWindow('path_name_if_needed/image_name.jpg','pop_up_name','width','height','scrolling_yes/no', 'pop_up_title')

Doing it like that might make the pop up blocker think it is 'user initiated'.

Also, you can still do it as rajug was suggesting with a bit of server side code to get the image from the query string in the link but, you would have less (if any) control over the window size and chrome.

Additionally, query strings can be processed via javascript but, this requires javascript be enabled and that the server isn't messing with the query string in any way that might confuse the script. The same limitations as using a server side query string would be still be present.