Home > Web Front-end > JS Tutorial > body text

js mouse and keyboard no operation example

小云云
Release: 2018-03-29 17:31:27
Original
1496 people have browsed it

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!