PDA

View Full Version : Click link in Lightbox, exit Lightbox



webted
02-18-2010, 10:08 PM
<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/dynamicindex4/lightbox2/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?

jscheuer1
02-19-2010, 04:32 AM
This id="bottomNavClose" business in your link can do no good here, please get rid of it.

What you want to execute is:


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


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


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.

webted
02-21-2010, 03:49 PM
Hi John, Thank so much, this works great.