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?
Asked
Active
Viewed 4,615 times
1 Answers
0
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" rel="lightbox">
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 lightbox fires off.

Community
- 1
- 1

Shawn Steward
- 6,773
- 3
- 24
- 45
-
Thanks Shawn. Simulating a click was a great idea, I actually went ahead and just used Prototypes default click action to simulate a click. Worked like a charm. – aegenes Aug 10 '10 at 01:33
-
Ok cool, I am not familiar with Prototype and couldn't easily find how they did that. – Shawn Steward Aug 10 '10 at 15:28