Welcome aboard! We are happy you are here and wish you good net-raft!
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
var text = document.createElement("p");
var timeoutInMiliseconds = 5000;
var timeoutId;
function startTimer() {
timeoutId = window.setTimeout(doInactive, timeoutInMiliseconds)
}
function doInactive() {
text.innerHTML = "you are idle!";
document.getElementsByTagName('body')[0].appendChild(text);
}
function resetTimer() {
text.innerHTML = "";
document.getElementsByTagName('body')[0].appendChild(text);
window.clearTimeout(timeoutId)
startTimer();
}
function setupTimers () {
document.onmousemove = resetTimer;
document.onmousedown = resetTimer;
document.onkeypress = resetTimer;
document.onkeyup = resetTimer;
document.onscroll = resetTimer;
document.ondblclick = resetTimer;
document.onclick = resetTimer;
startTimer();
}
// initialization
setupTimers();
</script>
</body>
</html>
The most helpful JAVASCRIPT solutions
How can I get the last day and the next day in javascript ?JAVASCRIPT Click to see more ... 5.9K 508