Results 1 to 3 of 3

Thread: Click link in Lightbox, exit Lightbox

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

    Arrow Click link in Lightbox, exit Lightbox

    HTML Code:
    <a href="welcome_signs/01.jpg" rel="lightbox" title="Order Moose Welcome Sign" rev="welcome_signs.htm#bottom" id="bottomNavClose"> <img border="1" src="01.png" width="118" height="180">
    http://www.dynamicdrive.com/dynamici...box2/index.htm

    This seems rather simple, but I am using Lightbox and when the user clicks the link, I want to exit the lightbox and re-direct to the bottom of the page (not a new page). It works to bring me to the bottom of the page via HTML anchoring but the lightbox is still up?

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

    Default

    This id="bottomNavClose" business in your link can do no good here, please get rid of it.

    What you want to execute is:

    Code:
    myLightbox.end();
    But where and when? The answer of course is when the generated link is clicked, not when the activating link (what you have in your previous post) is clicked. To do this we need to edit the lightbox.js file. It should be here (around line #361 in that file):

    Code:
    		function getImageTitle(anchor){ //DynamicDrive.com added function that allows the caption("title") to be linked ("rev").
    			var ddimageTitle=anchor.getAttribute('title')
    			var ddimageTitleURL=(ddimageTitle!=null && ddimageTitle!="")? anchor.getAttribute('rev') : null
    			return ddimageTitleFinal=(ddimageTitleURL!=null && ddimageTitleURL!="")? '<a href="'+ddimageTitleURL+'" class="ddcaptionurl">'+ddimageTitle+'</a>' : ddimageTitle
    		};
    Find that section in the lightbox.js file and make it like so (addition highlighted):

    Code:
    		function getImageTitle(anchor){ //DynamicDrive.com added function that allows the caption("title") to be linked ("rev").
    			var ddimageTitle=anchor.getAttribute('title')
    			var ddimageTitleURL=(ddimageTitle!=null && ddimageTitle!="")? anchor.getAttribute('rev') : null
    			return ddimageTitleFinal=(ddimageTitleURL!=null && ddimageTitleURL!="")? '<a onclick="myLightbox.end();return true;" href="'+ddimageTitleURL+'" class="ddcaptionurl">'+ddimageTitle+'</a>' : ddimageTitle
    		};
    This is untested. So if you have problems with it let me know and:

    Please post a link to a page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

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

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

    Default

    Hi John, Thank so much, this works great.

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
  •