思路:
使用 mousemover 事件来监测是否有用户操作页面,写一个定时器间隔特定时间检测是否长时间未操作页面,如果是,退出;
具体时间代码如下(js):
var lastTime = new Date().getTime();
var currentTime = new Date().getTime();
var timeOut = 10 * 60 * 1000; //设置超时时间: 10分
$(document).ready(function(){
/* 鼠标移动事件 */
$(document).mousemove(function(){
lastTime = new Date().getTime(); //更新操作时间

});
});

function testTime(){
currentTime = new Date().getTime(); //更新当前时间
if(currentTime - lastTime > timeOut){ //判断是否超时
console.log("超时");
}
}

/* 定时器 间隔1秒检测是否长时间未操作页面 */
window.setInterval(testTime, 1000);

如不用jq可修改为对应的js

var lastTime = new Date().getTime();
var currentTime = new Date().getTime();
var timeOut = 10 * 60 * 1000; //设置超时时间: 10分

window.onload=function (){
window.document.onmousemove=function(){
lastTime = new Date().getTime(); //更新操作时间
}
};

function testTime(){
currentTime = new Date().getTime(); //更新当前时间
if(currentTime - lastTime > timeOut){ //判断是否超时
console.log("超时");
}
}

/* 定时器 间隔1秒检测是否长时间未操作页面 */
window.setInterval(testTime, 1000);

最新文章

  1. Qt - QThread(翻译帮助文档)
  2. SQL Server游标
  3. Deep learning:四十四(Pylearn2中的Quick-start例子)
  4. 无损破解Android图案密码及原理
  5. ZOJ2006 (最小表示法)
  6. struts2中action中的通配符
  7. oracle 查看表的相关信息
  8. Android(java)学习笔记157:使用Dexdump等工具进行反编译
  9. [转] nginx+FastCGI+c++
  10. Apple Watch视频教程(连载)
  11. 常见的Message Queue应用场景
  12. Luogu 1111 修复公路(最小生成树)
  13. jdbc封装的类
  14. [运维工具]linux下远程桌面rdesktop安装和使用
  15. 语音识别ASR - HTK(HResults)计算字错率WER、句错率SER
  16. ucos之互斥信号量及优先级反转
  17. MySQL使用普通用户访问返回ERROR 1698 (28000): Access denied for user 'root'@'localhost'
  18. python的static方法和class方法
  19. Android Studio自定义组合控件
  20. Java中equals,hashcode

热门文章

  1. #阿里云#云服务器部署Django(基础篇)
  2. word转html 压缩图片网站
  3. (转)MySQL中show语法
  4. 如何安装windows7
  5. ERROR:org.apache.hadoop.hbase.PleaseHoldException: Master is initializing 解决方案
  6. C++的函数对象优于函数指针地方
  7. golang协程池
  8. 8-lvs-负载均衡
  9. Maven Source Plugin
  10. Golang 并发Groutine实例解读(一)