View Full Version : call lightbox from a function

02-06-2009, 11:51 AM
hi guys

I have been trying for sometime now to call lightbox from a function. I suppose the question is can I structure a function so to call lightbox and load a given image?

any clues or ideas really appreciate.

many thanks



02-06-2009, 02:54 PM
This depends so much upon the version of Lightbox that you are using. I believe it can be done in all versions, but the syntax is different, and some versions would require at least slight modification first.

If you are using this version (2.03a):


It is easiest if you have an anchor link, but you can create one and you don't even need to append it to the document, or you could use an existing (visible or invisible) anchor link.

Let's say an invisible existing anchor link with a unique id:

<a id="u1" href="some_image.jpg" style="display: none;" rel="lightbox" title="This is my caption"></a>

Once you have that and the page has loaded using the version of Lightbox that I've linked to, you may do in javascript:


08-05-2010, 02:33 PM
This doesn't work for me.

I get a javascript error: myLightbox is not defined.

08-05-2010, 04:07 PM
open a new thread for a new question.