search

Home  >  Q&A  >  body text

java session问题

对于一个网页长时间没有操作,给用户一个对话框的提示,但是用户的基本信息还是可以获取到;有没有办法实现

PHPzPHPz2892 days ago209

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-04-18 09:23:12

    Is it more appropriate to do it on the front end?

    The front-end js is used as a monitor. If there is neither mouse operation nor keyboard operation for a long time (for example: 30 minutes), a box will pop up to remind the user.

    Correction:

    What I gave before was pseudo-code, which was only meaningful and not guaranteed to be correct, but the questioner obviously took it seriously, so I had no choice but to change it a little bit, at least it can run

    For example:

    var timer;
    
    var setTimer = function(){
        timer = setTimeout(function() {
            alert('你大爷的,也不动一动?');
            setTimer();
        }, 5000);
    };
    
    setTimer();
    
    var handler = function(){
        clearTimeout(timer);
        setTimer();
    };
    
    document.addEventListener('keyup', handler, false);
    document.addEventListener('mousemove', handler, false);

    reply
    0
  • Cancelreply