带延迟的触发灯箱onLoad [英] Trigger Lightbox onLoad w/ Delay
问题描述
任何熟悉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屋!