diff options
author | MDN <actions@users.noreply.github.com> | 2021-06-29 00:35:05 +0000 |
---|---|---|
committer | MDN <actions@users.noreply.github.com> | 2021-06-29 00:35:05 +0000 |
commit | 2d478fb11c4864129dffb10cb43630b2aaf26bc0 (patch) | |
tree | 61561b7187a5a2fa57eded7e64c2a74c52efe15e /files/zh-cn/orphaned/web | |
parent | 19ba3e27d010ae914a441870b7d4f02ce2d35f7d (diff) | |
download | translated-content-2d478fb11c4864129dffb10cb43630b2aaf26bc0.tar.gz translated-content-2d478fb11c4864129dffb10cb43630b2aaf26bc0.tar.bz2 translated-content-2d478fb11c4864129dffb10cb43630b2aaf26bc0.zip |
[CRON] sync translated content
Diffstat (limited to 'files/zh-cn/orphaned/web')
-rw-r--r-- | files/zh-cn/orphaned/web/api/childnode/after/index.html | 176 | ||||
-rw-r--r-- | files/zh-cn/orphaned/web/api/oscillatornode/stop/index.html | 122 |
2 files changed, 298 insertions, 0 deletions
diff --git a/files/zh-cn/orphaned/web/api/childnode/after/index.html b/files/zh-cn/orphaned/web/api/childnode/after/index.html new file mode 100644 index 0000000000..76792e7638 --- /dev/null +++ b/files/zh-cn/orphaned/web/api/childnode/after/index.html @@ -0,0 +1,176 @@ +--- +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/oscillatornode/stop/index.html b/files/zh-cn/orphaned/web/api/oscillatornode/stop/index.html new file mode 100644 index 0000000000..be94b576e6 --- /dev/null +++ b/files/zh-cn/orphaned/web/api/oscillatornode/stop/index.html @@ -0,0 +1,122 @@ +--- +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> |