Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Nov 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Detect screen idle time

    Dear all,

    I would like to know if javascript can detect the screen idle time, if certain time come up in idle, then it will redirect to another page, any help will be appreciate, thanks!

    Eddie

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,965
    Thanks
    0
    Thanked 236 Times in 233 Posts
    You might get some idea from this thread.

  • #3
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Something like this:-

    Code:
    <body onload = "checktime()">
    
    <script type="text/javascript">
    var count = 0;
    var tim;
    function checktime() {
    count ++;
    if (count=10) {  // 10 seconds but better extend to several minutes
    window.location.href = "http://www.google.com"
    }
    tim = setTimeout(checktime,1000);
    }
    
    document.onkeydown = function( evt ) {
    evt = evt || event;
    count = 0;
    window.clearTimeout(tim);
    setTimeout(checktime,1000);
    }
    
    document.onmousedown = function(evt) { 
    evt = evt || window.event; 
    count = 0;
    window.clearTimeout(tim);
    setTimeout(checktime,1000);
    }
    
    </script>

    Brevior saltare cum deformibus mulieribus est vita - Life is too short to dance with ugly women
    Last edited by Philip M; 01-12-2012 at 12:11 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Something like this:-

    Code:
    <body onload = "checktime()">
    
    <script type="text/javascript">
    var count = 0;
    var tim;
    function checktime() {
    count ++;
    if (count=10) {  // 10 seconds
    window.location.href = "http://www.google.com"
    }
    tim = setTimeout(checktime,1000);
    }
    
    document.onkeydown = function( evt ) {
    evt = evt || event;
    count = 0;
    window.clearTimeout(tim);
    setTimeout(checktime,1000);
    }
    
    document.onmousedown = function(evt) { 
    evt = evt || window.event; 
    count = 0;
    window.clearTimeout(tim);
    setTimeout(checktime,1000);
    }
    
    </script>

    Brevior saltare cum deformibus mulieribus est vita - Life is too short to dance with ugly women

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Posting Permissions

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