Results 1 to 6 of 6

Thread: Lightbox v2.03 (caption link wont open in new window)

  1. #1
    Join Date
    Jan 2008
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Post Lightbox v2.03 (caption link wont open in new window)

    1) Script Title: Lightbox v2.03

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...box2/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 -

  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

    Replace:

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

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

    Code:
    <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.
    Last edited by jscheuer1; 01-31-2008 at 08:22 PM. Reason: correct the code
    - John
    ________________________

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

  3. #3
    Join Date
    Jan 2008
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thanks alot it works perfectly

  4. #4
    Join Date
    Jan 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default please help

    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

  5. #5
    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

    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.
    - John
    ________________________

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

  6. #6
    Join Date
    Jan 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for a fast reply....its working now!

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
  •