|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Monitoring Browser Inactivity
Hi,
I have a problem where I want to close the browser window if the user has not performed any activity for five minutes. I am coding in ASP and also VBScript on NT4, using IIS4. Is there any way of doing this? Thanks alot, Irfan. |
|
#2
|
|||
|
|||
|
Hi Irgan,
There sure is. You need to use JavaScript however: <script language="JavaScript"> funciton setCloseTimer() { window.setTimeout("window.close()", 300000); } </script> <body onLoad="setCloseTimer()"> .... </body> That should do it. Play around with the 300000 to match the time required. |
|
#3
|
|||
|
|||
|
btw the time of 300,000 millisecs is 50min! so just remove on of those 0's to make it 5 mins
have fun |
|
#4
|
|||
|
|||
|
Thanks very much.
Regards, Irfan |
|
#5
|
|||
|
|||
|
Ben, I think your maths needs brushing up
![]() 1 second is 1000 milliseconds, so 1 minute is 60,000 (60 x 1000) 5 minutes is 300,000 (5 x 60000 or three hundred thousand). So Mytch was right. Your suggestion of 30,000 ms would only be 30 seconds. Mytch was right again with the setTimeOut function, however using the Timeout after a body onload would close the window regardless of user activity after the set time (5 mins), even if it was being used at the time. Very annoying!! A better way to use the setTimeout in this way would be to check for mouse movement or key presses, and set the TimeOut if no movement. Have a function saying something along the lines of: If mouse_position change / key_press then reset setTimeOut. Can't think offhand what the actual code would be, but this gives you an idea. Then call this function in a body onload. As long as you move the mouse or keep typing the TimeOut resets itself, but if you leave the screen alone for a few seconds, the timeout kicks in, until you type something again. Hope that helped. Nautilus |
|
#6
|
|||
|
|||
|
yeah i realised after i posted and couldnt be bothered to edit it
i was thinkin 1/100 hehe oh well |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Monitoring Browser Inactivity |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|