diff options
Diffstat (limited to 'files/zh-cn/web/api')
-rw-r--r-- | files/zh-cn/web/api/eventtarget/attachevent/index.html | 94 | ||||
-rw-r--r-- | files/zh-cn/web/api/idbkeyrange/index.html | 40 | ||||
-rw-r--r-- | files/zh-cn/web/api/window/scrollto/index.html | 6 |
3 files changed, 26 insertions, 114 deletions
diff --git a/files/zh-cn/web/api/eventtarget/attachevent/index.html b/files/zh-cn/web/api/eventtarget/attachevent/index.html index 3ddf224034..41ce03185b 100644 --- a/files/zh-cn/web/api/eventtarget/attachevent/index.html +++ b/files/zh-cn/web/api/eventtarget/attachevent/index.html @@ -1,96 +1,8 @@ --- title: 为这个EventTarget附加事件. slug: Web/API/EventTarget/attachEvent +tags: + - Junk translation_of: Web/API/EventTarget/addEventListener --- -<p>{{APIRef("DOM Events")}}</p> - -<p>{{ Non-standard_header() }}</p> - -<h2 id="摘要">摘要</h2> - -<p>这是早期IE浏览器(IE8及早期版本)的一个专有的替代性标准,替代EventTarget.addEventListener()方法,{{domxref("EventTarget.addEventListener()")}} 方法</p> - -<h2 id="Syntax" name="Syntax">语法</h2> - -<pre class="syntaxbox"><em>attached</em> = <em>target</em>.attachEvent(<em>eventNameWithOn</em>, <em>callback</em>) - -</pre> - -<dl> - <dt> 作用的元素(target)</dt> - <dd>一个用于监听事件的文档对象模型元素</dd> - <dt>事件名伴随On(eventNameWithOn)</dt> - <dd>监听的事件名以on前置,类似一个属性的管理者,譬如当你使用onclick时能够监听你的click事件</dd> - <dt>回调函数</dt> - <dd>当目标触发事件时回调函数被调用。这个函数被调用时不带参数,并且这些都将设置在<a href="/en-US/docs/Web/API/Window/window"><code>window</code> object.</a>这个对象中</dd> - <dt>附加</dt> - <dt> 是否成功附加上属性会以布尔值表示</dt> -</dl> - -<h2 id="规范">规范</h2> - -<p>不存在于任何标准规范中</p> - -<p>微软在MSDN有详细描述 <a href="https://msdn.microsoft.com/en-us/library/ms536343(v=vs.85).aspx">has a description on MSDN</a>.</p> - -<h2 id="Browser_Compatibility" name="Browser_Compatibility">浏览器是否合适</h2> - -<p>{{ CompatibilityTable() }}</p> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari (WebKit)</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>6 thru 10 [1]</td> - <td>{{ CompatUnknown() }}</td> - <td>{{ CompatNo() }}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Phone</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatUnknown() }}</td> - <td>{{ CompatUnknown() }}</td> - <td>{{ CompatNo() }}</td> - </tr> - </tbody> -</table> -</div> - -<p>[1]: <code>attachEvent()</code> 不再被IE11支持。</p> - -<p>{{domxref("EventTarget.addEventListener()")}}被IE9+支持.</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li>{{domxref("EventTarget.detachEvent()")}}</li> - <li>{{domxref("EventTarget.fireEvent()")}}</li> -</ul> +<p>{{DOMxRef("EventTarget.addEventListener","EventTarget.addEventListener()")}}</p> diff --git a/files/zh-cn/web/api/idbkeyrange/index.html b/files/zh-cn/web/api/idbkeyrange/index.html index 32481c3a02..af65cfbb11 100644 --- a/files/zh-cn/web/api/idbkeyrange/index.html +++ b/files/zh-cn/web/api/idbkeyrange/index.html @@ -16,10 +16,10 @@ translation_of: Web/API/IDBKeyRange <p>{{APIRef("IndexedDB")}}</p> <div> -<p>The <strong><code>IDBKeyRange</code></strong> interface of the <a href="/en/IndexedDB" title="en/IndexedDB">IndexedDB API</a> represents a continuous interval over some data type that is used for keys. Records can be retrieved from {{domxref("IDBObjectStore")}} and {{domxref("IDBIndex")}} objects using keys or a range of keys. You can limit the range using lower and upper bounds. For example, you can iterate over all values of a key in the value range A–Z.</p> +<p><a href="/en/IndexedDB" title="en/IndexedDB">IndexedDB API</a> 的<strong><code>IDBKeyRange</code></strong>接口表示一些数据类型上的键的连续间隔。可以使用一个键或某个范围的键从{{domxref("IDBObjectStore")}} 和{{domxref("IDBIndex")}} 对象中检索记录。您也可以指定键的上界和下界来限制范围。例如,您可以遍历值范围a - z中的键的所有值。</p> </div> -<p>A key range can be a single value or a range with upper and lower bounds or endpoints. If the key range has both upper and lower bounds, then it is <em>bounded</em>; if it has no bounds, it is <em>unbounded</em>. A bounded key range can either be open (the endpoints are excluded) or closed (the endpoints are included). To retrieve all keys within a certain range, you can use the following code constructs:</p> +<p>键范围可以是单个值,也可以是具有上界、下界或端点的范围。如果键范围同时有上界或下界,那么它是有界的,否则是无界的。有界键范围可以是开放的(不包含端点)或闭合的(包含了端点)。要检索一定范围内的所有键值,可以使用以下的代码结构:</p> <table class="standard-table"> <thead> @@ -66,21 +66,21 @@ translation_of: Web/API/IDBKeyRange </thead> </table> -<p>A key is in a key range if the following conditions are true:</p> +<p>如果以下条件为true,则键包含在键范围中:</p> <ul> - <li>The lower value of the key range is one of the following: + <li>键范围的下界值为以下值或符合以下条件之一时: <ul> <li><code>undefined</code></li> - <li>Less than key value</li> - <li>Equal to key value if <code>lowerOpen</code> is <code>false</code>.</li> + <li>低于正在被鉴定的键值</li> + <li>等于正在被鉴定的键值,且键范围的<code>lowerOpen属性</code>为<code>false</code>.</li> </ul> </li> - <li>The upper value of the key range is one of the following: + <li>键范围的上界值为以下值或符合以下条件之一时: <ul> <li><code>undefined</code></li> - <li>Greater than key value</li> - <li>Equal to key value if <code>upperOpen</code> is <code>false</code>.</li> + <li>高于正在被鉴定的键值</li> + <li>等于正在被鉴定的键值,且键范围的<code>upperOpen<font face="Arial, x-locale-body, sans-serif"><span style="background-color: #ffffff;">属性为</span></font></code><code>false</code>.</li> </ul> </li> </ul> @@ -91,13 +91,13 @@ translation_of: Web/API/IDBKeyRange <dl> <dt>{{domxref("IDBKeyRange.lower")}} {{readonlyInline}}</dt> - <dd>Lower bound of the key range.</dd> + <dd>键范围的下界</dd> <dt>{{domxref("IDBKeyRange.upper")}} {{readonlyInline}}</dt> - <dd>Upper bound of the key range.</dd> + <dd>键范围的上界</dd> <dt>{{domxref("IDBKeyRange.lowerOpen")}} {{readonlyInline}}</dt> - <dd>Returns false if the lower-bound value is included in the key range.</dd> + <dd>如果下界值包含在键范围内,则返回false。</dd> <dt>{{domxref("IDBKeyRange.upperOpen")}} {{readonlyInline}}</dt> - <dd>Returns false if the upper-bound value is included in the key range.</dd> + <dd>如果上界值包含在键范围内,则返回false。</dd> </dl> <h2 id="Methods">Methods</h2> @@ -106,31 +106,31 @@ translation_of: Web/API/IDBKeyRange <dl> <dt>{{domxref("IDBKeyRange.bound()")}}</dt> - <dd>Creates a new key range with upper and lower bounds.</dd> + <dd>指定上界和下界来创建一个新的键范围</dd> <dt>{{domxref("IDBKeyRange.only()")}}</dt> - <dd>Creates a new key range containing a single value.</dd> + <dd>指定单个键值来创建一个新的键范围</dd> <dt>{{domxref("IDBKeyRange.lowerBound()")}}</dt> - <dd>Creates a new key range with only a lower bound.</dd> + <dd>指定结果集的下界来创建一个新的键范围</dd> <dt>{{domxref("IDBKeyRange.upperBound()")}}</dt> - <dd>Creates a new upper-bound key range.</dd> + <dd>指定结果集的上界来创建一个新的键范围</dd> </dl> <h3 id="Instance_methods">Instance methods</h3> <dl> <dt>{{domxref("IDBKeyRange.includes()")}}</dt> - <dd>Returns a boolean indicating whether a specified key is inside the key range.</dd> + <dd>返回一个布尔值来表示指定的键是否在键范围内。</dd> </dl> <h2 id="Examples">Examples</h2> -<p>The following example illustrates how you'd use a key range. Here we declare a <code>keyRangeValue</code> as a range between values of "A" and "F". We open a transaction (using {{domxref("IDBTransaction")}}) and an object store, and open a Cursor with {{domxref("IDBObjectStore.openCursor")}}, declaring <code>keyRangeValue</code> as its optional key range value. This means that the cursor will only retrieve records with keys inside that range. This range includes the values "A" and "F", as we haven't declared that they should be open bounds. If we used <span style="background-color: #fafbfc; font-family: consolas,monaco,andale mono,monospace; font-size: 1rem; line-height: 19px; white-space: pre;">IDBKeyRange.bound("A", "F", true, true);</span>, then the range would not include "A" and "F", only the values between them.</p> +<p>以下示例用以说明该如果使用键范围。在此我们将 <code>keyRangeValue</code> 声明为A~F之间的范围。我们打开一个事务 (使用 {{domxref("IDBTransaction")}}) 和一个对象存储, 并用 {{domxref("IDBObjectStore.openCursor")}}打开一个游标,其中<code>keyRangeValue</code>是一个可选的键范围值,指定之后游标将只检索键在该范围内的记录。这里的键范围包括了“A”和“F”,因为我们还没声明键范围为开放边界。如果我们使用 <span style="background-color: #fafbfc; font-family: consolas,monaco,andale mono,monospace; font-size: 1rem; line-height: 19px; white-space: pre;"><code>IDBKeyRange.bound("A", "F", true, true);</code>,那么这个键范围将不包括</span>“A”和“F”,只包含它们之间的值。</p> <div class="note"> <p><strong>Note</strong>: For a more complete example allowing you to experiment with key range, have a look at our <a href="https://github.com/mdn/indexeddb-examples/tree/master/idbkeyrange">IDBKeyRange-example</a> repo (<a href="https://mdn.github.io/indexeddb-examples/idbkeyrange/">view the example live too</a>.)</p> </div> -<pre class="brush: js">function displayData() { +<pre class="brush: js notranslate">function displayData() { var keyRangeValue = IDBKeyRange.bound("A", "F"); var transaction = db.transaction(['fThings'], 'readonly'); diff --git a/files/zh-cn/web/api/window/scrollto/index.html b/files/zh-cn/web/api/window/scrollto/index.html index 715e3f0190..83cc7657aa 100644 --- a/files/zh-cn/web/api/window/scrollto/index.html +++ b/files/zh-cn/web/api/window/scrollto/index.html @@ -11,7 +11,7 @@ translation_of: Web/API/Window/scrollTo <h2 id="Syntax" name="Syntax">语法</h2> -<pre><code>window.scrollTo(x<em>-coord</em>,<em>y-coord</em> )</code> +<pre class="notranslate"><code>window.scrollTo(x<em>-coord</em>,<em>y-coord</em> )</code> <code>window.scrollTo(options)</code></pre> @@ -26,7 +26,7 @@ translation_of: Web/API/Window/scrollTo <ol> <li><code><em>top</em></code> 等同于 <code><em>y-coord</em></code></li> <li><font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.5);">left</span></font> 等同于 <code>x<em>-coord</em></code></li> - <li><code><em>behavior</em></code><em> 类型String,表示滚动行为,支持参数 smooth(平滑滚动),instant(瞬间滚动),默认值auto,实测效果等同于instant</em></li> + <li><code><em>behavior</em></code><em> 类型String,表示滚动行为,支持参数 smooth(平滑滚动),instant(瞬间滚动),默认值auto</em></li> </ol> <dl> @@ -34,7 +34,7 @@ translation_of: Web/API/Window/scrollTo <h2 id="Example" name="Example">例子</h2> -<pre>window.scrollTo( 0, 1000 ); +<pre class="notranslate">window.scrollTo( 0, 1000 ); <code>// 设置滚动行为改为平滑的滚动 window.scrollTo({ |