Page Timeout and Automatic Redirect

SteveoAtilla

Regular
Joined
Dec 22, 2004
Messages
80
Location
The Frozen Tundra
Hello!

I have a customer that is using kiosk-type machines for multiple users. What they would like to happen is, after X minutes of inactivity, the page will re-direct to their Kiosk Home Page.

I have found a few posts about a java applet that can be loaded onto the page to run and keep track of inactivity, but have not seen any code.

Does anyone have a solution that would work?

Thanks,

Steveo
 
Here's a simple approach:
Code:
<script language="javascript" type="text/javascript">

var date = new Date();

document.onmousemove = function(event)
{
   date = new Date();
};

function check()
{
   var amount = new Date() - date;

   // display for debugging purposes
   window.status = amount;

   if (amount > 5000)
   {
     // user has not moved the mouse in the past 5 seconds
     // so we should redirect them...
     window.location = "http://www.espn.com";
   }
   else
   {
     setTimeout("check()", 1000);
   }
}

</script>

<body onload="check()">
You could also hook keyboard related events if you wanted and update the "date" variable.
 
Back
Top