Home >Web Front-end >JS Tutorial >js mouse and keyboard no operation example

js mouse and keyboard no operation example

小云云
小云云Original
2018-03-29 17:31:271511browse

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!

Statement:
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