我有一个测试网站(index.html),打开一个弹出窗口(popup.html),并在三秒钟后关闭它。下面是index.html的头:如何在x秒后自动关闭fancybox/lightbox/... popup?
<script language="javascript" type="text/javascript">
function popup(url) {
newwindow=window.open(url,'name','height=70,width=300');
if (window.focus) {newwindow.focus()}
return false;
}
</script>
这里的index.html的身体:
<a href="#" onClick="return popup('popup.html')">Open in pop-up</a>
这里的popup.html的头:
<script>
var howLong = 3000;
t = null;
function closeMe(){
t = setTimeout("self.close()",howLong);
}
</script>
这里的弹出的身体.html:
<body onLoad="closeMe();self.focus()">
<p>Closing in 3 seconds</p>
</body>
我想使用linghtbox/fancybox /任何...显示该弹出窗口,并在3秒后再次关闭它。我该怎么做?我尝试了各种各样的东西,没有任何工作。实现这个最简单的方法是什么?
在此先感谢!
的fancybox等灯箱有一个被称为开放的回调函数,以及一个公共的方法来关闭它,你尝试过触发回调函数内关闭方法(带超时)? – mariogl 2012-02-25 12:17:02
检查[documentation](http://fancybox.net/api)。 $ .fancybox.close();与setTimeout应该足够你。 – 2012-02-25 12:40:10