Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> <script> let inactivityTime = function() { let time; window.onload = resetTimer; document.onmousemove = resetTimer; document.onkeypress = resetTimer; function logout() { alert("You are now logged out.") } function resetTimer() { clearTimeout(time); time = setTimeout(logout, 2000) } }; window.onload = function() { inactivityTime(); } </script> </body> </html>