空闲计时器不工作
我有两个 jQuery 空闲计时器,一个在下面,另一个是类似的代码,其超时值高于第一个。我评论了第二个的超时值。这两个脚本运行在同一个 xhtml 页面上。当第一个模式(超时时间较低的模式)弹出时,我无法关闭它,而且它也不会在“myTimeout”值之后进入重定向页面。
(function($){
var timer;
//var timeout = 600000;
//var myTimeOut = 120000;
var timeout = 120000;
var myTimeOut = 60000;
$(document).bind("idle.idleTimer", function(){
$( "#popup-modal" ).dialog({
modal: true,
autoOpen: true,
width: 574,
resizable : false,
draggable:false,
open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); $(".ui-dialog-print").hide(); $(".ui-icon").hide(); },
show: {effect: 'fade'}
});
timer = window.setTimeout(function()
{ window.location.href = "redirectpage.xhtml";},myTimeOut);
});
$(document).bind("active.idleTimer", function(){
timeout = 120000;
window.clearTimeout(timer);
});
$.idleTimer(timeout);
})(jQuery);
I have two jQuery idle timers one below and the other is similar code with timeout values higher than the first one. I commented timeout values for the second one. The two scripts are running on the same xhtml page. When the first modal(one with lower timeout) pops up, I can't close it and also it doesn't go to the redirect page after the "myTimeout" value.
(function($){
var timer;
//var timeout = 600000;
//var myTimeOut = 120000;
var timeout = 120000;
var myTimeOut = 60000;
$(document).bind("idle.idleTimer", function(){
$( "#popup-modal" ).dialog({
modal: true,
autoOpen: true,
width: 574,
resizable : false,
draggable:false,
open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); $(".ui-dialog-print").hide(); $(".ui-icon").hide(); },
show: {effect: 'fade'}
});
timer = window.setTimeout(function()
{ window.location.href = "redirectpage.xhtml";},myTimeOut);
});
$(document).bind("active.idleTimer", function(){
timeout = 120000;
window.clearTimeout(timer);
});
$.idleTimer(timeout);
})(jQuery);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过为对话框的关闭事件添加处理程序?
此外,您似乎在打开对话框时隐藏了用于关闭对话框的默认控件。
您还有用于关闭对话框的按钮(或其他控件)吗?
最后,为了澄清问题,您似乎希望在用户处于不活动状态 60 秒后重定向用户,但如果用户再次活动则取消重定向。
这就是你想要实现的目标吗?
希望这有帮助。
皮特
Have you tried adding a handler for the dialog's close event?
Also, you appear to be hiding the default controls for closing the dialog when the dialog is opened.
Do you still have a button (or other control) with which to close the dialog?
Finally, to clarify the problem, it looks like you want to redirect the user after 60 seconds of inactivity but cancel the redirect if they become active again.
Is that what you are trying to accomplish?
Hope this helps.
Pete