javascript - setInterval() is not working properly for inactive tab -
i developing 1 timer taking record of time. using setinterval method of java script problem it's not working if tab inactive.
one solution got store old time , subtract new time 1 problem if after starting timer if user change system time affect on timer. please inform me if there other possible way or solution.
timerinterval = setinterval(function() { seconds=seconds+1; if(seconds==60) { minutes=minutes+1; if(minutes==60) { minutes=0; hours=hours+1; } $("#task"+adata['taskid']).html(("0" + hours).slice(-2)+":"+("0" + minutes).slice(-2)); seconds=0; } },1000);
try settimeout
instead of setinterval
setinterval
not prioritize calling function depending on browser load. have gone through same problem , resolved using settimeout
Comments
Post a Comment