0

Possible Duplicate:
Detecting idle time in JavaScript elegantly.

I have a table with some rows that I want to refresh for example every 10 minutes. Is there a way I can do this, but only if the user isn't currently active on that page?

Is there for example anything like an inactivity timer or something in JavaScript?

Community
  • 1
  • 1
Svish
  • 152,914
  • 173
  • 462
  • 620
  • @Peter J's answer looks most interesting in that question – Pekka Sep 04 '10 at 09:43
  • @pekka: I disagree, I don't think mouse movement should be the basis of idle time. When reading a page, I use me keyboard for scrolling and my mouse for links. – Andy E Sep 04 '10 at 09:52
  • 1
    @Andy good point! The solution fails there. The Idle time plugin linked by @Moin claims to listen to keypress events too. – Pekka Sep 04 '10 at 09:54
  • Yeah, seems like that is about what I'm asking. Voting to close as well :) – Svish Sep 04 '10 at 10:13
  • 2
    @Pekka: yes, I would think a combination of keydown and mousemove events should work well enough for idle time. At least, I can't think of any other way of not being idle on a web page :-) – Andy E Sep 04 '10 at 10:33

1 Answers1

1

you should be able to use this and accomplish what you need: http://www.erichynds.com/jquery/a-new-and-improved-jquery-idle-timeout-plugin/

have a look at the options and the onIdle option, adding your function here should do the trick

Moin Zaman
  • 25,281
  • 6
  • 70
  • 74
  • this is likely to be closed as a duplicate. Why not add your answer in the other question as well? As far as I can see, it's not there yet and it's good info. – Pekka Sep 04 '10 at 10:00