Home >Web Front-end >JS Tutorial >js mouse and keyboard no operation example
This article mainly shares with you examples of js mouse and keyboard no operation. It is mainly shared with you in the form of code. I hope it can help you.
<script> var count = 0; var outTime=30;//分钟 window.setInterval(go, 1000); function go() { count++; if (count == outTime*60) { alert("您因长时间未进行操作导致页面过期"); } } var x ; var y ; //监听鼠标 document.onmousemove = function (event) { var x1 = event.clientX; var y1 = event.clientY; if (x != x1 || y != y1) { count = 0; } x = x1; y = y1; }; //监听键盘 document.onkeydown = function () { count = 0; };</script>
The above is the detailed content of js mouse and keyboard no operation example. For more information, please follow other related articles on the PHP Chinese website!