문제

Possible Duplicate:
Detecting idle time in JavaScript elegantly

In a web application that I'm developing, on every page of the application, when nothing happens for a set amount of time, the page should automatically change. I think setting window.location will do for the latter part.

However, when it comes to detecting that nothing has happened, I'm a bit stuck. I'd think that binding all keyboard and mouse events to a single handler could do it, but I'm wondering if there is a better way. Has anyone done this before?

도움이 되었습니까?

해결책

Detecting idle time in JavaScript elegantly seems to miss the blur and focus events on the window. The basic approach is as you suggested but I'd take a close look at which events exactly you're binding on.

다른 팁

Aren't running your site on a web server? A web server, such as Tomcat, can check if a session timed out.

In tomcat's web.xml you would add or change a setting:

<session-config>
    <session-timeout>60</session-timeout>
 </session-config>

In case of a session timeout, you could redirect to another page.

Here is an example:

https://stackoverflow.com/a/1027592/1916258

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top