Results 1 to 4 of 4

Thread: call lightbox from a function

  1. #1
    Join Date
    Feb 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default call lightbox from a function

    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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/dynamici...box2/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:

    HTML Code:
    <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:

    Code:
    myLightbox.start(document.getElementById('u1'));
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This doesn't work for me.

    I get a javascript error: myLightbox is not defined.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    open a new thread for a new question.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •