SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member loganathan's Avatar
    Join Date
    Nov 2005
    Location
    Vellore-Chennai-TN
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Idle time detection using javascript

    I want to capture the system idle time. if the user did not press any key or did not move the mouse for particular time, then it is considered as system idle time... how to do it in javascript?
    ---
    Loganathan N, BOSCO ITS, Yellagi Hills, Chennai, India
    http://www.boscoits.com

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Use the clearTimeout() and setTimeout() functions whenever there is a mouse or keyboard event with the setTimeout triggering the function you want to have run after the appropriate amount of idle time. That way that function will only run when the required idle time occurs as any mouse or keyboard event will cancel the existing timeout call and start a new one.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if I'm at a.jsp and use window.open() to get b.jsp (which will redirect to another website), how to check if the pop up window is idle or its is still active?

    a.jsp
    ...
    var childWindow = window.open('b.jsp','childWindow ');
    ...

    b.jsp
    ...
    //redirect to 3rd party content
    location.href='xxx.xyz.xxx/x.html';
    ...

    Currently we have time tracking,but we hope the time tracking will stop after childWindow idle more then 5 minutes.

    I've tried childWindow.location.href or childWindow.history.length but all failed due to security reason. Is there anyway to check popup window's status?

  4. #4
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On all related events like mousemove, mouseup, mousedown keyup, keydown ...
    clearTimeout(thecurrentTimeout); thecurrentTimeout = setTimeout(setIdle,30000);//30s

  5. #5
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for reply.

    I've tried some code for the related events, but we can't use any of those when the pop up window actually displaying content from different domain. You'll see 'Access is denied' in IE and 'Error: uncaught exception: Permission denied to get property HTMLDocument.url' in FireFox.

    Is there any tricks to handle this security issue?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •