PC监听鼠标和键盘事件,定时无响应退出
2024-08-28 02:26:01
直接上代码:
window.onload = function () {
initScreenSaver();
} //0912 add
function ScreenSaver(settings){ this.settings = settings; this.nTimeout = this.settings.timeout; document.body.screenSaver = this;
// link in to body events
document.body.onmousemove = ScreenSaver.prototype.onevent;
document.body.onmousedown = ScreenSaver.prototype.onevent;
document.body.onkeydown = ScreenSaver.prototype.onevent;
document.body.onkeypress = ScreenSaver.prototype.onevent; var pThis = this;
var f = function(){pThis.timeout();}
this.timerID = window.setTimeout(f, this.nTimeout);
}
ScreenSaver.prototype.timeout = function(){
if ( !this.saver ){
window.history.back(-1)//无动作跳转地址
}
}
ScreenSaver.prototype.signal = function(){
if ( this.saver ){
this.saver.stop();
} window.clearTimeout(this.timerID); var pThis = this;
var f = function(){pThis.timeout();}
this.timerID = window.setTimeout(f, this.nTimeout);
} ScreenSaver.prototype.onevent = function(e){
this.screenSaver.signal();
} var saver;
function initScreenSaver(){
saver = new ScreenSaver({timeout:20000}); //无动作时间
}
最新文章
- JavaScript学习笔记-表达式和语句
- [Cocos2D-x For WP8]ParallaxNode视差
- 解决ArcGIS API for Silverlight 加载地图的内外网访问问题
- hql语句理解2
- 《同一个类中不同方法之间的调用相关问题(省略的类名或者this)》
- [转载]求平方根sqrt()函数的底层算法效率问题
- 数据分析≠Hadoop+NoSQL,不妨先看完善现有技术的10条捷径(分享)
- Java——(六)Collection之Queue集合
- PHP扩展开发(2) - VS2013环境搭建
- 第2阶段——编写uboot之硬件初始化和制作链接脚本lds(1)
- [struts2学习笔记] 第四节 学着使用struts 2的tag标签
- linux基础-系统安装教程篇(centos6.5)
- Flask框架简介,常用扩展包及两大核心
- 通过Cloudera Manager部署CDH5.15.1的webUI界面详解
- ASP.NET MVC中MaxLength特性设置无效
- linux上源码编译安装mysql-5.6.28
- SpringBoot+SpringAOP+Java自定义注解+mybatis实现切库读写分离
- 【甘道夫】HBase基本数据操作详解【完整版,绝对精品】
- PEP8 Python 编码规范整理(转)
- Java基础教程(13)--包