Reload webpage on idle

Discussion in 'Programming' started by six5tring, Jul 31, 2013.

Share This Page

  1. six5tring

    six5tring Silent Kristian Konsumer

    Joined:
    Oct 1, 2004
    Messages:
    3,251
    Likes Received:
    0
    Hi all,

    I am trying to make a simple webpage that can run locally on a PC without internet access that when no mouse or keyboard commands happen for a few minutes changes webpage (for the moment I've just put in bbc as example). However this does not seem to work. What do I need to do? It's been years since i've had to play with anything more than plain html. Can anyone help! My copying and pasting isn't getting me anywhere today!

    Ben

    Code:
    
    
    idleTime = 0;
    $(document).ready(function () {
        //Increment the idle time counter every minute.
        var idleInterval = setInterval("timerIncrement()", 60000); // 1 minute
    
        //Zero the idle timer on mouse movement.
        $(this).mousemove(function (e) {
            idleTime = 0;
        });
        $(this).keypress(function (e) {
            idleTime = 0;
        });
    })
    function timerIncrement() {
        idleTime = idleTime + 1;
        if (idleTime > 20) { // 20 minutes
            document.location.href="http://bbc.co.uk";
        }
    }
    
    
    
    Test Page
    
    
     
  2. six5tring

    six5tring Silent Kristian Konsumer

    Joined:
    Oct 1, 2004
    Messages:
    3,251
    Likes Received:
    0
    SORTED! I was being a muppet.

    Ben