带延迟的触发灯箱onLoad [英] Trigger Lightbox onLoad w/ Delay

查看:92
本文介绍了带延迟的触发灯箱onLoad的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何熟悉Lightbox2的人( http://www.huddletogether.com/projects/lightbox2/)知道如何触发灯箱onLoad并最好延迟1分钟?

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?

推荐答案

我使用了另一个SO帖子中的一些信息来模拟click事件: 使用原型触发事件

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

event.simulate.js 中获取代码并在文件中添加参考.

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

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

向要自动触发的锚链接添加 id :

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>

delay()函数中的数字是灯箱启动前要等待的秒数.

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

这篇关于带延迟的触发灯箱onLoad的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆