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 GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
clearTimeout | ||||||||||||||
Available in workers |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.