diff options
author | Florian Merz <me@fiji-flo.de> | 2021-02-11 12:56:40 +0100 |
---|---|---|
committer | Florian Merz <me@fiji-flo.de> | 2021-02-11 12:56:40 +0100 |
commit | 310fd066e91f454b990372ffa30e803cc8120975 (patch) | |
tree | d5d900deb656a5da18e0b60d00f0db73f3a2e88e /files/zh-cn/web/api/windowtimers/cleartimeout | |
parent | 8260a606c143e6b55a467edf017a56bdcd6cba7e (diff) | |
download | translated-content-310fd066e91f454b990372ffa30e803cc8120975.tar.gz translated-content-310fd066e91f454b990372ffa30e803cc8120975.tar.bz2 translated-content-310fd066e91f454b990372ffa30e803cc8120975.zip |
unslug zh-cn: move
Diffstat (limited to 'files/zh-cn/web/api/windowtimers/cleartimeout')
-rw-r--r-- | files/zh-cn/web/api/windowtimers/cleartimeout/index.html | 150 |
1 files changed, 0 insertions, 150 deletions
diff --git a/files/zh-cn/web/api/windowtimers/cleartimeout/index.html b/files/zh-cn/web/api/windowtimers/cleartimeout/index.html deleted file mode 100644 index 4b20c970d7..0000000000 --- a/files/zh-cn/web/api/windowtimers/cleartimeout/index.html +++ /dev/null @@ -1,150 +0,0 @@ ---- -title: WindowOrWorkerGlobalScope.clearTimeout() -slug: Web/API/WindowTimers/clearTimeout -tags: - - API - - WindowOrWorkerGlobalScope - - clearTimeout -translation_of: Web/API/WindowOrWorkerGlobalScope/clearTimeout ---- -<div> -<div>{{APIRef("HTML DOM")}}</div> -</div> - -<p>{{domxref("WindowOrWorkerGlobalScope")}}内置的<strong><code>clearTimeout()</code></strong>方法取消了先前通过调用{{domxref("WindowOrWorkerGlobalScope.setTimeout", "setTimeout()")}}建立的定时器。</p> - -<h2 id="Syntax" name="Syntax">语法</h2> - -<pre class="notranslate"><em>scope</em>.clearTimeout(<em>timeoutID</em>)</pre> - - - -<h3 id="Parameters">Parameters</h3> - -<dl> - <dt><code>timeoutID</code></dt> - <dd>您要取消定时器的标识符。 该ID由相应的<code>setTimeout()</code>调用返回。</dd> -</dl> - -<p>值得注意的是,{{domxref("WindowOrWorkerGlobalScope.setTimeout", "setTimeout()")}}和{{domxref("WindowOrWorkerGlobalScope.setInterval", "setInterval()")}}使用共享的ID池, 意味着在技术上可以混用<code>clearTimeout()</code>和{{domxref("WindowOrWorkerGlobalScope.clearInterval", "clearInterval()")}} 。 但是,为了清楚起见,你应该避免这样做。</p> - -<h2 id="Example" name="Example">示例</h2> - -<p>在一个网页中运行如下脚本,并且点击一次页面。一秒钟后你会看见弹出一条信息。如果你在一秒内不停点击页面,弹出框将不再出现。</p> - -<pre class="brush: js notranslate">var alarm = { - remind: function(aMessage) { - alert(aMessage); - delete this.timeoutID; - }, - - setup: function() { - this.cancel(); - var self = this; - this.timeoutID = window.setTimeout(function(msg) {self.remind(msg);}, 1000, "Wake up!"); - }, - - cancel: function() { - if(typeof this.timeoutID == "number") { - window.clearTimeout(this.timeoutID); - delete this.timeoutID; - } - } -}; -window.onclick = function() { alarm.setup() };</pre> - -<h2 id="Notes" name="Notes">注意</h2> - -<p>传入一个错误的 ID 给 <code>clearTimeout()</code>不会有任何影响;也不会抛出异常。</p> - -<h2 id="Specification" name="Specification">规范</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - <tr> - <td>{{SpecName('HTML WHATWG', 'webappapis.html#dom-cleartimeout', 'WindowOrWorkerGlobalScope.clearTimeout()')}}</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-cleartimeout', 'clearTimeout()')}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td></td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容">浏览器兼容</h2> - -<p>{{CompatibilityTable}}</p> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Edge</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>1.0</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoDesktop("1")}}<br> - {{CompatGeckoDesktop("52")}}<sup>[1]</sup></td> - <td>4.0</td> - <td>4.0</td> - <td>1.0</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Edge</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>1.0</td> - <td>1.0</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoMobile("1")}}<br> - {{CompatGeckoMobile("52")}}<sup>[1]</sup></td> - <td>6.0</td> - <td>6.0</td> - <td>1.0</td> - </tr> - </tbody> -</table> -</div> - -<p>[1] <code>clearTimeout()</code> now defined on {{domxref("WindowOrWorkerGlobalScope")}} mixin.</p> - -<h2 id="See_also" name="See_also">更多</h2> - -<ul> - <li>{{domxref("WindowTimers.setTimeout()")}}</li> - <li>{{domxref("WindowTimers.setInterval()")}}</li> - <li>{{domxref("WindowTimers.clearInterval()")}}</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> |