Open/Close Lightbox from JavaScript


I feel like I should be able to figure this out but I am not having much luck. Someone from SitePoint introduced me to Lightbox and I really like what you can do with it. What I am trying to figure out but having difficulty with is opening and closing a Lightbox from JavaScript.

For example, if I use this html…

<a href=“#testLB” rel=“testLB” class=“lbOn”>Test Lightbox</a>

It will display a div since I coded this div in the HTML file…

<div id="testLB" class="leightbox">

    <a href="javascript: test();">Change Zip</a>

What I want to be able to do is to display this div with Lightbox but do it from JavaScript. For example, from the body onLoad event I would like to call a JavaScript function that opens a Lightbox.

Then, the Lightbox is going to contain a few fields so I was going to have JavaScript validate that the user entered all the fields. If they did, I then want to close the Lightbox. If they did not, I will display an alert message. I can get all of this to work except having JavaScript close (actually, it is hiding) a Lightbox div. Can someone help me figure out how to hide the div from a JavaScript function?

What I downloaded was Lightbox Gone Wild which I think is also called Leightbox.

Thanks in advance for your time and knowledge.

This took me a while and I am not sure if someone knows a different may, but here is how I got it to work. After many hours on Google doing searches, I came across this site. It details the changes that need to be made to lightbox.js in order to allow JavaScript to activate/deactivate a Lightbox.

I then used this code to active…

function testActivate()
   lb = new lightbox();

I then used this code to deactivate…

function testDeactivate()
   lb = new lightbox();