diff options
Diffstat (limited to 'files/zh-cn/web/api/windoworworkerglobalscope/clearinterval/index.html')
-rw-r--r-- | files/zh-cn/web/api/windoworworkerglobalscope/clearinterval/index.html | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/windoworworkerglobalscope/clearinterval/index.html b/files/zh-cn/web/api/windoworworkerglobalscope/clearinterval/index.html new file mode 100644 index 0000000000..9a2d6e1790 --- /dev/null +++ b/files/zh-cn/web/api/windoworworkerglobalscope/clearinterval/index.html @@ -0,0 +1,74 @@ +--- +title: WindowTimers.clearInterval() +slug: Web/API/Window/clearInterval +tags: + - API + - WindowOrWorkerGlobalScope + - 参考 + - 方法 +translation_of: Web/API/WindowOrWorkerGlobalScope/clearInterval +--- +<div>{{ApiRef("HTML DOM")}}</div> + +<p>{{domxref("WindowOrWorkerGlobalScope")}} mixin 的 <strong><code>clearInterval()</code></strong> 方法可取消先前通过 {{domxref("WindowOrWorkerGlobalScope.setInterval", "setInterval()")}} 设置的重复定时任务。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"><em>scope</em>.clearInterval(<var>intervalID</var>) +</pre> + +<h3 id="Parameters">Parameters</h3> + +<dl> + <dt><code>intervalID</code></dt> + <dd>要取消的定时器的 ID。是由 <code>setInterval()</code> 返回的。</dd> +</dl> + +<p>值得一提的是,{{domxref("WindowOrWorkerGlobalScope.setInterval", "setInterval()")}} 和 {{domxref("WindowOrWorkerGlobalScope.setTimeout", "setTimeout()")}} 共用其定义的 IDs,即可以使用 <code>clearInterval()</code> 和 {{domxref("WindowOrWorkerGlobalScope.clearTimeout", "clearTimeout()")}} 中的任意一个。然而,为了使代码可读性更强,你应该尽量避免这种用法。</p> + +<h3 id="返回值">返回值</h3> + +<p>{{jsxref("undefined")}}</p> + +<h2 id="示例">示例</h2> + +<p>查看 <a href="/en-US/docs/DOM/window.setInterval#Example"><code>setInterval()</code> 的示例</a>。</p> + +<h2 id="Specification" name="Specification">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">规范</th> + <th scope="col">状态</th> + <th scope="col">备注</th> + </tr> + <tr> + <td>{{SpecName('HTML WHATWG', 'webappapis.html#dom-clearinterval', 'WindowOrWorkerGlobalScope.clearInterval()')}}</td> + <td>{{Spec2("HTML WHATWG")}}</td> + <td>Method moved to the <code>WindowOrWorkerGlobalScope</code> mixin in the latest spec.</td> + </tr> + <tr> + <td>{{SpecName('HTML WHATWG', 'webappapis.html#dom-clearinterval', 'clearInterval()')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td></td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + + + +<p>{{Compat("api.WindowOrWorkerGlobalScope.clearInterval")}}</p> + +<h2 id="参见">参见</h2> + +<ul> + <li><a href="/en-US/docs/JavaScript/Timers" title="JavaScript/Timers">JavaScript 定时器</a></li> + <li>{{domxref("WindowOrWorkerGlobalScope.setTimeout")}}</li> + <li>{{domxref("WindowOrWorkerGlobalScope.setInterval")}}</li> + <li>{{domxref("WindowOrWorkerGlobalScope.clearTimeout")}}</li> + <li>{{domxref("Window.requestAnimationFrame")}}</li> + <li><a href="/en-US/docs/JavaScript/Timers/Daemons" title="JavaScript/Timers/Daemons"><em>Daemons</em> management</a></li> +</ul> |