Skip to content Skip to sidebar Skip to footer

Trigger Lightbox Onload W/ Delay

Does anyone familiar with Lightbox2 (http://www.huddletogether.com/projects/lightbox2/) know how to trigger a lightbox onLoad and preferably with a 1 minute delay?

Solution 1:

I used some info from another SO post to simulate the click event: Trigger an event with Prototype

Get the code from event.simulate.js and include a reference in your file.

<scriptsrc="js/simulate.js"type="text/javascript"></script>

Add an id to the anchor link you want to auto-fire:

<a href="images/image-1.jpg"id="openLink" >

Then at the bottom of your file insert this code (or put in external file):

<scripttype="text/javascript">functionopenLightbox() {
        $('openLink').simulate('click');
    }
    document.observe("dom:loaded", function() {
        openLightbox.delay(5);
    });
</script>

The number in the delay() function is the number of seconds you want to wait before the fires off.

Post a Comment for "Trigger Lightbox Onload W/ Delay"