setInterVal/clearInterval

Sep 23, 2018

Hi All,

So I have to build in a timer using javascript. What we are looking to do is if someone leaves the course open for an extended timeframe I pop a JS alert.

I have a counter and it will fire the JS alert. Then if I go to the next page the JS alert will fire again right off the bat. I am unable to get it to reset.

Can someone please let me know what I am missing.

Thanks

var player=GetPlayer();
clearInterval(myVar);
var myVar;
var Sec = 0;
myFunction();
function myFunction() {
var Sec = 10000 //4 hrs = 14400 or 28800 = 8 hrs
myVar = setInterval(alertFunc, Sec);
}

function alertFunc() {
clearInterval(myVar);
var Sec = 0;
alert("Hello!");
myFunction();
}

1 Reply

This discussion is closed. You can start a new discussion or contact Articulate Support.