diff options
Diffstat (limited to 'files/zh-cn/orphaned/web/api')
13 files changed, 1373 insertions, 0 deletions
diff --git a/files/zh-cn/orphaned/web/api/analysernode/fft/index.html b/files/zh-cn/orphaned/web/api/analysernode/fft/index.html new file mode 100644 index 0000000000..f553738351 --- /dev/null +++ b/files/zh-cn/orphaned/web/api/analysernode/fft/index.html @@ -0,0 +1,7 @@ +--- +title: Directory failure 目录失效 +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 new file mode 100644 index 0000000000..2b7022c1ce --- /dev/null +++ b/files/zh-cn/orphaned/web/api/audiocontext/mozaudiochanneltype/index.html @@ -0,0 +1,95 @@ +--- +title: AudioContext.mozAudioChannelType +slug: Web/API/AudioContext/mozAudioChannelType +translation_of: 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 new file mode 100644 index 0000000000..eb82534aed --- /dev/null +++ b/files/zh-cn/orphaned/web/api/audionode/connect(audioparam)/index.html @@ -0,0 +1,163 @@ +--- +title: AudioNode.connect(AudioParam) +slug: Web/API/AudioNode/connect(AudioParam) +translation_of: 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/document/cookie/simple_document.cookie_framework/index.html b/files/zh-cn/orphaned/web/api/document/cookie/simple_document.cookie_framework/index.html new file mode 100644 index 0000000000..450751cefa --- /dev/null +++ b/files/zh-cn/orphaned/web/api/document/cookie/simple_document.cookie_framework/index.html @@ -0,0 +1,218 @@ +--- +title: 简单的cookie框架 +slug: Web/API/Document/cookie/Simple_document.cookie_framework +tags: + - Cookies + - cookie +translation_of: 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/entity/index.html b/files/zh-cn/orphaned/web/api/entity/index.html new file mode 100644 index 0000000000..2e05365217 --- /dev/null +++ b/files/zh-cn/orphaned/web/api/entity/index.html @@ -0,0 +1,52 @@ +--- +title: Entity +slug: Web/API/Entity +translation_of: 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 new file mode 100644 index 0000000000..9bd7699388 --- /dev/null +++ b/files/zh-cn/orphaned/web/api/fetchobserver/index.html @@ -0,0 +1,145 @@ +--- +title: FetchObserver +slug: Web/API/FetchObserver +translation_of: 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/msselection/index.html b/files/zh-cn/orphaned/web/api/msselection/index.html new file mode 100644 index 0000000000..5760848324 --- /dev/null +++ b/files/zh-cn/orphaned/web/api/msselection/index.html @@ -0,0 +1,103 @@ +--- +title: MSSelection +slug: Web/API/MSSelection +tags: + - API + - DHTML + - DOM + - 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> + +<div class="hidden">此页上的兼容性表是从结构化数据生成的。如果您想贡献数据,请访问 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 并向我们发送一个请求。</div> + +<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 new file mode 100644 index 0000000000..8506bc5266 --- /dev/null +++ b/files/zh-cn/orphaned/web/api/namelist/index.html @@ -0,0 +1,48 @@ +--- +title: NameList +slug: Web/API/NameList +translation_of: 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/navigatorplugins/测试滕盖/index.html b/files/zh-cn/orphaned/web/api/navigatorplugins/测试滕盖/index.html new file mode 100644 index 0000000000..3f9c09d768 --- /dev/null +++ b/files/zh-cn/orphaned/web/api/navigatorplugins/测试滕盖/index.html @@ -0,0 +1,38 @@ +--- +title: 测试滕盖 +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/notification/sound/index.html b/files/zh-cn/orphaned/web/api/notification/sound/index.html new file mode 100644 index 0000000000..ffe90b4955 --- /dev/null +++ b/files/zh-cn/orphaned/web/api/notification/sound/index.html @@ -0,0 +1,129 @@ +--- +title: Notification.sound +slug: Web/API/notification/sound +translation_of: 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/textrange/text/index.html b/files/zh-cn/orphaned/web/api/textrange/text/index.html new file mode 100644 index 0000000000..ae485dd58e --- /dev/null +++ b/files/zh-cn/orphaned/web/api/textrange/text/index.html @@ -0,0 +1,72 @@ +--- +title: TextRange.text +slug: Web/API/TextRange/text +tags: + - API + - DHTML + - DOM + - TextRange +--- +<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> + +<div class="hidden">此页上的兼容性表是从结构化数据生成的。如果您想贡献数据,请访问 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 并向我们发送一个请求。</div> + +<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/websockets_api/websocket_server_vb.net/index.html b/files/zh-cn/orphaned/web/api/websockets_api/websocket_server_vb.net/index.html new file mode 100644 index 0000000000..3969f9c5ea --- /dev/null +++ b/files/zh-cn/orphaned/web/api/websockets_api/websocket_server_vb.net/index.html @@ -0,0 +1,270 @@ +--- +title: WebSocket Server Vb.NET +slug: Web/API/WebSockets_API/WebSocket_Server_Vb.NET +translation_of: 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 new file mode 100644 index 0000000000..f17531eb18 --- /dev/null +++ b/files/zh-cn/orphaned/web/api/window/getattention/index.html @@ -0,0 +1,33 @@ +--- +title: Window.getAttention() +slug: Web/API/Window/getAttention +translation_of: 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> |