treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Backbox/Lightbox - close on click on image.

  • Hello everyone

    I'll try to ask here then - on another javascript forum they didn't wanna help me.

    I'm completely new to javascript but I managed to "install" the backbox script on my site (only a test site) I got the script from http://www.javascriptkit.com/script/script2/backbox/# All works fine but I would like to close the image not only by clicking outside of box or at the Close-button - but also by clicking the image itself.

    The orignal script works really well - except for one small thing - when the backbox displays large images - I can't close them by clicking outside the image on the left and right sides - it only works closing when I click above or under the box.

    Anyway - an internet search gave me this small code which is supposed to work:

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


    And I was wondering if you guys know where to put it in the lightbox.jg file for it to work (or if it even will work at all?) - Or maybe I can change the original code for this to happen (Without adding this new code?)