View Full Version : How do you write a javascript to open images?

09-29-2008, 01:35 AM
I have seen this feature on many websites.
There is a list of 10 photo thumnails on display, example
<img src="pix1tn.jpg"><img src="pix2tn.jpg">..<img src="pix10tn.jpg">

When you move the mouse to a thumnail, say pix2tn, and click on it, it opens a small window showing photo (pix2.jpg) using javascript instead of a new html page. The new picture window displays the larger photo and has 3 buttons, one to close the window, one to close this pix and show the previous pix (pix1.jpg), and one to close this pix and show the next pix (pix3.jpg).

I thought this was a simple task, but when I looked at its javascript and tried to make changes to it, it didn't work.
I need some help on this javascript for my personal website. If it's not against any codingforums' rules, I would offer $25 paypal money for the first person that posts the working javascript.

The code on the html shows something like <div class="movie-stills-thumbnail"><a href="javascript:open_picture_viewer(2)"><img id="movie-stills-thumbnail-2" src="pix2tn.jpg" width="63" height="35"></a></div>

The (2) in this case indicates the pix to be displayed will be pix2.jpg.


09-29-2008, 01:47 AM
You're looking for a lightbox script. You can find a few on Dynamic Drive.


rnd me
09-30-2008, 12:11 PM
if you changed open_picture_viewer, you could avoid having to pass any arguments.
this would let you cut and paste the same thing in each tag, saving a bit of time.