当前位置: 首页 > 面试题库 >

javascript:清除所有超时?

堵泽宇
2023-03-14
问题内容

有没有办法清除给定窗口中的所有超时?我认为超时存储在window对象中的某个位置,但无法确认。

任何跨浏览器解决方案都是受欢迎的。


问题答案:

它们不在window对象中,但是具有id,这些id是连续的整数。

因此,您可以像这样清除所有超时:

var id = window.setTimeout(function() {}, 0);

while (id--) {
    window.clearTimeout(id); // will do nothing if no timeout with id is present
}


 类似资料:
  • 问题内容: 如何使用JavaScript删除当前域的所有cookie? 问题答案: 请注意,此代码有两个限制: 它不会删除设置了标志的cookie ,因为该标志会禁用Javascript对cookie的访问。 它不会删除已设置值的cookie 。(尽管这些cookie会出现在中,但您必须在未指定与它相同的值的情况下将其删除。)

  • void clear_all_cache(int expire time) This clears the entire template cache. As an optional parameter, you can supply a minimum age in seconds the cache files must be before they will get cleared. 清除所

  • void clear_all_assign() This clears the values of all assigned variables. 清除所有已赋值到模板中的值。 Example 13-5. clear_all_assign 例子 13-5. 清除所有赋值 // clear all assigned variables $smarty->clear_all_assign();

  • 问题内容: 我有2个单独的数组列表。一个叫做spawnList,另一个叫做FoundList 我已经运行了代码,它生成了一个实体并将所述实体ID添加到spawnList,所以现在spawnList.size()等于1 下一步运行该操作将清除foundList搜索实体,并将发现的内容与spawnList进行比较,所有匹配项都将添加到foundList中。 我遇到的怪异问题是当foundList被清除

  • 我们设置了几个ActiveMQ Artemis 2.17.0集群,以便在数据中心之间使用镜像进行复制。 在ActiveMQ Artemis 2.17.0或更高版本中有什么方法可以实现这一点吗?