浏览器是否会跟踪活动的计时器 ID? [英] Does the browser keep track of active timer IDs?

查看:35
本文介绍了浏览器是否会跟踪活动的计时器 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

浏览器是否跟踪活动的 setIntervalsetTimeout ID?或者这完全取决于开发人员来跟踪?

Does the browser keep track of active setInterval and setTimeout IDs? Or is this solely up to the developer to keep track of?

如果它确实跟踪它们,是否可以通过 BOM 访问?

If it does keep track of them, is it accessible via the BOM?

推荐答案

开发人员需要跟踪.您可以通过使用 setTimeout/setInterval 函数的返回值并将该值传递给 clearTimeout/clearInterval 函数来实现 - 如此处的其他答案所述.

It is up for the developer to keep track of. You can do so by using the returned value of the setTimeout/setInterval function and passing that value to the clearTimeout/clearInterval function - as described in other answers here.

这似乎是因为每个浏览器都会以自己的方式实现对间隔的跟踪.

This appears to be because each browser will implement keeping track of the intervals in their own way.

来自 w3.org/TR/2009/WD-html5-20090212/no.html(草稿,但 w3schools 和 http://w3.org/TR/Window 以几乎相同的方式解释) - setTimeout 和 setInterval 返回一个 long 并且 clearTimeout/clearInterval 接受一个 long 以查找和取消

From w3.org/TR/2009/WD-html5-20090212/no.html (a draft, but w3schools and http://w3.org/TR/Window explain it almost the same way) - setTimeout and setInterval return a long and clearTimeout/clearInterval accept a long to find and cancel

这篇关于浏览器是否会跟踪活动的计时器 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆