Results 1 to 3 of 3

Thread: Lightbox Viewer v2.03a

  1. #1
    Join Date
    Apr 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Lightbox Viewer v2.03a

    When I hard code a link, the lightbox works just fine:
    Code:
    <a href="http://www.harpandharptrading.com/images/tractors/6640ford.jpg" rel="lightbox[trac1]" title="my caption">image #1</a>
    But, I need to create the links dynamically using javascript which I did with the following code:
    Code:
    var link = document.createElement("a");
    
    link.href = "images/tractors/6640ford.jpg";
    link.rel = "lightbox[trac1]";
    link.title = "my caption";
    link.innerHTML = "image1";
    The link appears and when I look at it with firebug, it looks the same as the one I hard coded. But, when i click the link it takes me to a new page with just the image on it like it would if I typed in the url to the image.

    Can someone help please?
    http://www.dynamicdrive.com/dynamici...box2/index.htm

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Lightbox is automatically initialized when the page first loads. If you're adding lightbox specific links dynamically, most likely they will not be parsed due to the timing of the former versus the later. After you've added the links dynamically to the page, try calling:

    Code:
    myLightbox = new Lightbox();
    at the end of your code again to reinitialize Lightbox.

  3. #3
    Join Date
    Apr 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi, and thanks for the reply.

    I tried putting
    Code:
    myLightbox = new Lightbox();
    in my function where I am creating the links. I dont get any errors but when i click the link, it isnt doing right.

    I also put it at the end of my javascript code and it gives me an error that says objBody has no properties and objBody.appendChild(objOverlay);

    Can you think of why this isn't working?

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
  •