Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

inactive user

Status
Not open for further replies.

TheCandyman

Technical User
Sep 9, 2002
761
US
I am thinking of ways i could see if a user is inactive to redirect them to another page. I don't want to use server sessions, so i was wondering if any of you have thought about this? Maybe a countdown on keystroke/mouse idleness??
 
Incase someone down the road finds this question, here is the answer i found:

in <head> section
Code:
<script language="JavaScript"><!--
if (document.layers) {
  window.captureEvents(Event.MOUSEMOVE);
}

window.onMouseMove = resetTimer;

var tID = '';

function resetTimer(e) {
  clearTimeout(tID); // reset the timer
  tID = setTimeout('executeTimer()',10000);
}

function executeTimer() {
  location.href = '[URL unfurl="true"]http://www.google.com';[/URL]
}
//--></script>

Code:
<body onLoad="tID = setTimeout('executeTimer()',10000)" onMouseMove="resetTimer()">
 
That, of course, only works if your definition of "inactive" is "hasn't moved the mouse in 10 seconds". You neither defined what you meant in your question (for others to help you), nor defined what you meant in the code you gave to help others.

Remember - other people may have a very different definition of "inactive" to you - so you should have clarified this in both of your posts, IMHO.

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
screwed [neutral]

j/k

after posting that code, i thought about it and changed it to include onkeydown="resetTimer()"> and my real code is set for 10 minutes. So if they don't move the mouse, or type anything for 10 minutes, SEE YA![peace]
 
Is there a genuinely good reason to do this? Since http is discontinuous protocol, it makes little difference if I move the mouse or not. Or so I would think.
 
You are right, but since this is javascript based it works. Unless javascript is turned off, but I don't have to worry about that because this will only be on a page running on my 10 computers. So if someone uses one, gets done and walks away. It redirect back to a start page(not google)
 
You may also have to think about the server session timeout as well. i.e. make sure it's in sync with the session timeout on the server as otherwise, although the user will have been directed to the start page, the session may still be active with any of the previous user's session variables.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Personally, I'd just let the server handle the redirect as each page is requested.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top