javascript 窗口在 15 分钟后关闭
现在,我的脚本可以工作,但前提是关闭的时间间隔很短(5 分钟有效),但是当我尝试将超时设置为 15 分钟时,它每次都会失败。我正在使用的脚本是:
function openClose(){
my_window = window.open('http://www.somesite.com',
"mywindow","status=1,width=1010,height=740"); //this should execute closepopup() after 15mins if my math is correct
setTimeout(closepopup,900000);
}
function closepopup(){
if(false == my_window.closed){
my_window.close();
}
}
Now, I have script that works, but only if time interval for closing is small (5mins works), but when I try to set timeout to 15mins, it fails every time. The script I'm using is:
function openClose(){
my_window = window.open('http://www.somesite.com',
"mywindow","status=1,width=1010,height=740"); //this should execute closepopup() after 15mins if my math is correct
setTimeout(closepopup,900000);
}
function closepopup(){
if(false == my_window.closed){
my_window.close();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是一个想法 - 垃圾收集器可以处理不需要的变量吗?我可以看到
my_window
是一个全局变量,请尝试保留计时器变量:请让我知道这是否适合您。
Just a thought - could garbage collector dispose unwanted variables? I can see that
my_window
is a global one, try to persist timer variable as well:Please, let me know if this works for you.