在空闲/不活动60秒后重定向用户? [英] Redirect user after 60 seconds of idling/inactivity?

查看:110
本文介绍了在空闲/不活动60秒后重定向用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在我的网站上使用JavaScript在60秒不活动后将用户重定向到 / logout 页面?

How can I use JavaScript on my site to redirect the user to a /logout page after 60 seconds of inactivity?

我知道设置计时器或使用元刷新标签很简单:但我只想重定向非活动用户,而不是破坏某人的活动会话/使用。

I know setting a timer or using a meta refresh tag is straightforward: but I only want to redirect inactive users, not disrupt someone's active session/usage.

这可以用JavaScript吗?

Is this possible with JavaScript?

推荐答案

我相信你是寻找这样的东西:

http://paulirish.com/2009 / jquery-idletimer-plugin /

I belive you are looking for something like this:
http://paulirish.com/2009/jquery-idletimer-plugin/

如果您自己编写代码,则需要捕获鼠标和键盘事件并重新启动计时器在任何这些事件之后。如果计时器达到阈值或从阈值倒计时到0,则可以重置页面的URL。

If you were to code that yourself, you would need to capture mouse and keyboard events and restart your timer after any of these events. If the timer ever reaches the threshold or counts down to 0 from the threshold you can reset the URL of the page.

这篇关于在空闲/不活动60秒后重定向用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆