1

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

4

1 回答 1

0

我使用了另一个 SO 帖子中的一些信息来模拟点击事件: Trigger an event with Prototype

event.simulate.js获取代码并在文件中包含参考。

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

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

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

然后在文件底部插入此代码(或放入外部文件):

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

delay() 函数中的数字是您希望在灯箱启动之前等待的秒数。

于 2010-08-09T21:35:33.110 回答