简体   繁体   中英

How do I keep the infinite timer that triggers JS function on html page?

I need to call a function that updates some JS objects on the page every 2 minutes. How would I do that?

I created a onload function and a countdown function that refreshes a whole page and therefore resets the timer until next page refresh, but this is not the way I want it. Is there a way to keep an infinite time loop?

I assume, if I could create a an infinite loop and do something like this:

if (currentSeconds%120==0){ 
callFunction();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM