WorkerGlobalScope:clearTimeout() 方法

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

备注: 此特性仅在 Web Worker 中可用。

WorkerGlobalScope 接口的 clearTimeout() 方法取消先前通过调用 setTimeout() 建立的超时任务。

如果参数未标识之前创建的操作,则此方法不执行任何动作。

语法

js
clearTimeout(timeoutID)

参数

timeoutID

你要取消定时器的标识符。该 ID 由相应的 setTimeout() 调用返回。

值得注意的是,setTimeout()setInterval() 共享同一个 ID 池,意味着在技术上可以混用 clearTimeout()clearInterval()。但是,为了清楚起见,你应该避免这样做。

返回值

无(undefined)。

示例

参见 Window.clearTimeout() 以获取示例。

备注

传入一个无效的 ID 给 clearTimeout() 不会有任何影响;也不会抛出异常。

规范

Specification
HTML
# dom-cleartimeout-dev

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
clearTimeout
Available in workers

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support

参见