The loop should only work on the last active tab? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

The loop should only work on the last active tab?

hi friends, I have a loop as below: setInterval( function() { do_something(); }, 1000); I want to run this loop only at the last active tab. For example: There are 1,2,3,4,5 tabs. If the 4th tab is active on browser, only run the loop on 4th tab. If no tabs are active, only run the loop on last active tab. What do you think about this?

16th Jun 2017, 10:32 AM
Sertan Gülveren
Sertan Gülveren - avatar
1 Answer
+ 1
How does the tab code look like? How do you monitor the active state of the selected tab? What doSomething function does? Could you share the your Code Playground code. Btw setInterval is not loop, it's timer function.
16th Jun 2017, 11:18 AM
Calviղ
Calviղ - avatar