PDA

View Full Version : call lightbox from a function



giacbus
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

regards

giacbus

jscheuer1
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):

http://www.dynamicdrive.com/dynamicindex4/lightbox2/index.htm

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:


myLightbox.start(document.getElementById('u1'));

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

I get a javascript error: myLightbox is not defined.

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