监听无鼠标、键盘动作
程序员文章站
2022-06-03 12:18:43
...
监听无鼠标键盘动作 10秒后提示超时
只使用于ff chrome ie9+
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
var keys=null;
function check(){
alert("超时 ")
}
function actionHd(e){
window.clearTimeout(keys)
keys=setTimeout("check()",10*1000);
}
function actionSet(hd){
if( window.outerWidth == undefined ){
document.body.onkeydown=hd;
document.body.onmousedown=hd;
document.body.onmousemove=hd;
}else{
onkeydown=hd;
onmousedown=hd;
onmousemove=hd;
}
}
function initCheckNoAction(){
actionSet(actionHd)
}
</script>
</head>
<body style=" " onload="initCheckNoAction()">
10秒不动就提示超时
</body>
</html>