闲置5分钟后如何更改页面位置 [英] How to change a page location after inactivity of 5 mins

查看:80
本文介绍了闲置5分钟后如何更改页面位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望如果我的页面上5分钟没有任何活动,那么该页面将被重定向到预定义页面.

I want that if there is no activity on my page for 5 mins then the page will be redirected to a predefined page.

任何人都可以建议我如何使用JavaScript或jQuery.

Can anyone suggest me how to do this using JavaScript or jQuery.

推荐答案

如果您想要一个真正的非活动控件,请使用此库(该控件也可以控制鼠标键盘活动) )

If you want a real inactivity control please use this library (which control mouse and keyboard activity too)

jQuery空闲计时器

The jQuery idletimer

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

这里是使用示例:

// idleTimer() takes an optional argument that defines the idle timeout
// timeout is in milliseconds; defaults to 30000
$.idleTimer(10000);


$(document).bind("idle.idleTimer", function(){
 // function you want to fire when the user goes idle
});


$(document).bind("active.idleTimer", function(){
 // function you want to fire when the user becomes active again
});

// pass the string 'destroy' to stop the timer
$.idleTimer('destroy');

这篇关于闲置5分钟后如何更改页面位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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