PDA

View Full Version : Lightbox v2.03 (caption link wont open in new window)



Beta Cygni
01-27-2008, 05:48 AM
1) Script Title: Lightbox v2.03

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/lightbox2/index.htm

3) Describe problem:

Basically im looking to have the caption title open in a seprate browser window. Im using the lightbox gallery out of a DHTML window and both scripts work just fine togeather except the following target tag dosent open a new window:

rev="path_and_name_of_file.html" target="_blank"

ive since realised in the Lightbox.js script [line 361 to 365] that this dosent account for target tags, i think:

'<a href="'+ddimageTitleURL+'" class="ddcaptionurl">'+ddimageTitle+'</a>'

I can attach any the page code that is needed.

Thanks for any help in advance.
- Beta Cygni -

jscheuer1
01-27-2008, 07:26 AM
Replace:


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
};

With:


function getImageTitle(anchor){ //DynamicDrive.com added function that allows the caption("title") to be linked ("rev").
var ddimageTitle=anchor.getAttribute('title')
var ddimageTarget=anchor.target? anchor.target : null
var ddimageTitleURL=(ddimageTitle!=null && ddimageTitle!="")? anchor.getAttribute('rev') : null
return ddimageTitleFinal=(ddimageTitleURL!=null && ddimageTitleURL!="")? '<a href="'+ddimageTitleURL+'" class="ddcaptionurl"'+(ddimageTarget? 'target="'+ddimageTarget+'"' : '')+'>'+ddimageTitle+'</a>' : ddimageTitle
};

Once you do that, you can add the target to the lightbox link(s):


<a href="some.jpg" title="Google"
rel="lightbox" rev="http://www.google.com/"
target="_blank">Link Text or Thumbnail Image Tag Here</a>

And, if you like, you can still have ones without target attributes on the same page.

Beta Cygni
01-27-2008, 08:26 PM
Thanks alot it works perfectly :)

mooboo
01-31-2008, 08:05 PM
The code works perfectly...but my main problem is when I put the code target="_self" on the lightbox it doesn't seem to work...it still open a new blank page. WHat I want is to open the page on the same browser.

<a href="some.jpg" title="Google"
rel="lightbox" rev="http://www.google.com/"
target="_self">Link Text or Thumbnail Image Tag Here</a>

Thanks in Advance
Gene Barrios

jscheuer1
01-31-2008, 08:27 PM
That's the default behavior of lightbox. So, you could choose simply to make no modification to the code.

However, if you wish to mix links that target other things with ones that open in the same window, use my revised code from my previous post. I just edited it to fix a typo in it. It will now open in the same window if the target is set to _self.

mooboo
01-31-2008, 08:59 PM
Thanks for a fast reply....its working now! :)