2

TIMER INTERVAL PROBLEM:

I'm trying to make a timer, but when I click off of the Timer tab the Timer's countdown stops (interval stops?). I tried using some jquery for the $(window).focus to continue counting down. I was unable to figure that out...

var timerInterval;
$(window).focus(function() {
    if (!timerInterval)
        timerInterval = setInterval(startTimer, 10);
});

$(window).blur(function() {
    if (!timerInterval)
        timerInterval = setInterval(startTimer, 10);
});

Here is the code for my Timer: https://codepen.io/0cean-Man/pen/NWyRPRX

DISCLAIMER: The Jquery is not working on codepen, I don't know how to make the js Jquery compadible on codepen.

Ocean
  • 21
  • 4
  • Does this answer your question? [How can I make setInterval also work when a tab is inactive in Chrome?](https://stackoverflow.com/questions/5927284/how-can-i-make-setinterval-also-work-when-a-tab-is-inactive-in-chrome) – Sumit Sharma May 12 '22 at 04:11
  • I looked at that but i don't really know exactly how to implement it into my own code... – Ocean May 12 '22 at 06:19

0 Answers0