Results 1 to 2 of 2

Thread: Redirect on non-activity???

Hybrid View

  1. #1
    Join Date
    Apr 2005

    Lightbulb Redirect on non-activity???


    Is there a way to refresh (redirect to another page) after no activity(no clicks, etc...) on a page?

    Maybe a "onClick...resetTimeout or something then have the page on a timeout refresh.

    Any help would be greatly appreciated.

    This, by the way, is for an interactive Kiosk touch screen tv. After a certain time, want it to go back to the main html page.

  2. #2
    Join Date
    Mar 2005
    Behind you...
    I'm sure this code could be improved, but this will get done what you need:
    <script type="text/javascript">
    var $redir = true;
    var $timeout;
    var $timer = 60000; // Reset time in milliseconds
    var $redirUrl = "http://www.google.com/"; // URL to redirect to
    function _CancelRedir() {
      $timeout = setTimeout("_Redir()", $timer);
    function _Redir() {
      if($redir == true) {
        document.location.href = $redirUrl;
      } else {
        $timeout = setTimeout("_Redir()", $timer);
    document.body.addEventListener('load', _Redir, false);
    document.body.addEventListener('click', _CancelRedir, false);
    document.body.addEventListener('keypress', _CancelRedir, false);
    You could add more event listeners (and probably optimize that code to work from an array of events) but this covers the basics. If anything on the page is clicked or any keys are pressed (not sure exactly how your kiosk is designed or setup) it will reset the timer (set to 60 seconds). If nothing on the page is clicked or no keys are pressed then in 60 seconds it will redirect to a URL you can set.
    "Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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