JAVASCRIPT fire event when is idle javascript - Net-Raft.com

Welcome aboard! We are happy you are here and wish you good net-raft!




Just a Web Code Solution
join us

fire event when user is idle javascript


 2563

Show ResultJAVASCRIPT


4

<!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>


By        
The power of the user (%)
18%



The most helpful JAVASCRIPT solutions

How can I get the last day and the next day in javascript ?How can I get the last day and the next day in javascript ?JAVASCRIPT

Click to see more ...

  5.3K     445

How to get client machine name or computer name with javascript ?How to get client machine name or computer name with javascript ?JAVASCRIPT

Click to see more ...

  23.4K     396

get client hostname javascriptget client hostname javascriptJAVASCRIPT

Click to see more ...

  4.8K     301

create 3d barrel using javascriptcreate 3d barrel using javascriptJAVASCRIPT

Click to see more ...

  3.5K     258

Create fireworks using javascriptCreate fireworks using javascriptJAVASCRIPT

Click to see more ...

  3.1K     204

create qr code javascriptcreate qr code javascriptJAVASCRIPT

Click to see more ...

  2.6K     205

detect ie javascriptdetect ie javascriptJAVASCRIPT

Click to see more ...

  2.8K     194

create earth in universe with three.jscreate earth in universe with three.jsJAVASCRIPT

Click to see more ...

  2.6K     182

how to create foreach class using javascript ?how to create foreach class using javascript ?JAVASCRIPT

Click to see more ...

  2.2K     180

fire event when user is idle javascriptfire event when user is idle javascriptJAVASCRIPT

Click to see more ...

  2.6K     181

Welcome aboard!
We are happy you are here and
wish you good net-raft!