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.

<script src="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):

<script type="text/javascript">
    function openLightbox() {
        $('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"