Results 1 to 6 of 6

Thread: Light Box 2 -- Close on image click

  1. #1
    Join Date
    Dec 2007
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Light Box 2 -- Close on image click

    1) Script Title: LightBox 2

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

    3) Describe problem:

    Does anyone know how to alter the lightbox.js script so that it will close when the image is clicked? LightBox 1, the first version, does this, but the second one is configured to close only on the close link at the bottom of the page and the shadow space. I think a nice improvement to this script would be to close it upon clicking the image.

    Best Wishes,
    James

  2. #2
    Join Date
    Feb 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It depends on whether you have a single image or multiple images, with one, it closes, with multiple it goes on to the next. If you click on the shaded area it also closes.

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

    I don't believe that's true, nexxosmedia. Try this (tested, works here), change:

    Code:
    		objLightbox.onclick = function(e) {	// close Lightbox is user clicks shadow overlay
    			if (!e) var e = window.event;
    			var clickObj = Event.element(e).id;
    			if ( clickObj == 'lightbox') {
    				myLightbox.end();
    			}
    		};
    to:

    Code:
    		objLightbox.onclick = function(e) {	// close Lightbox is user clicks shadow overlay
    			if (!e) var e = window.event;
    			var clickObj = Event.element(e).id;
    			if ( !/(prevLink)|(nextLink)/.test(clickObj) ) {
    				myLightbox.end();
    			}
    		};
    - John
    ________________________

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

  4. The Following User Says Thank You to jscheuer1 For This Useful Post:

    MugzMalone (02-25-2008)

  5. #4
    Join Date
    Dec 2007
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Very cool. Thank you, John! I have another issue with this script that I will post in a new thread.

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

    Default

    This is great! In my case the Close X buttom wasn't working on a server - it worked on a local computer just fine. I changed to the code above and now the visitor can click in any place and close the image.
    BTW, doesn't anyone knows how to fix thie problem with the Close X button? It seems like the image is not found on a server, but everything is fine on a local computer.

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

    Quote Originally Posted by Jessica445 View Post
    BTW, doesn't anyone knows how to fix thie problem with the Close X button? It seems like the image is not found on a server, but everything is fine on a local computer.
    That just means exactly what it says. The image is not found on the server. So, either the image wasn't uploaded to the server, or if it was, it wasn't to the location expected by the script. Here (in lightbox.js) is where the location of the close image is set:

    Code:
    // -----------------------------------------------------------------------------------
    
    //
    //	Configuration
    //
    var fileLoadingImage = "images/loading.gif";		
    var fileBottomNavCloseImage = "images/closelabel.gif";
    
    var animate = true;	// toggles resizing animations
    var resizeSpeed = 7;	// controls the speed of the image resizing animations (1=slowest and 10=fastest)
    
    var borderSize = 10;	//if you adjust the padding in the CSS, you will need to update this variable
    
    // -----------------------------------------------------------------------------------
    That would be relative to the page using the script, but the path may be made absolute. In fact, if the script is used by more than one page(s) in different folders, an absolute path must be used. Example of an absolute path:

    Code:
    var fileBottomNavCloseImage = "http://www.mydomain.com/images/closelabel.gif";
    If you need more help:

    Please post a link to the 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

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
  •