aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/text
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/text
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/text')
-rw-r--r--files/zh-cn/web/api/text/assignedslot/index.html89
-rw-r--r--files/zh-cn/web/api/text/index.html195
-rw-r--r--files/zh-cn/web/api/text/iselementcontentwhitespace/index.html29
-rw-r--r--files/zh-cn/web/api/text/replacewholetext/index.html36
-rw-r--r--files/zh-cn/web/api/text/splittext/index.html127
-rw-r--r--files/zh-cn/web/api/text/text/index.html96
-rw-r--r--files/zh-cn/web/api/text/wholetext/index.html141
7 files changed, 713 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/text/assignedslot/index.html b/files/zh-cn/web/api/text/assignedslot/index.html
new file mode 100644
index 0000000000..860697d7bf
--- /dev/null
+++ b/files/zh-cn/web/api/text/assignedslot/index.html
@@ -0,0 +1,89 @@
+---
+title: HTMLSlotElement.assignedSlot
+slug: Web/API/Text/assignedSlot
+translation_of: Web/API/Text/assignedSlot
+---
+<p>{{SeeCompatTable}}{{APIRef("Shadow DOM")}}</p>
+
+<p><span class="seoSummary"><code><font face="Open Sans, arial, x-locale-body, sans-serif"><span style="background-color: #ffffff;"> </span></font><strong>assignedSlot</strong></code> 是 {{domxref("Text")}} 接口的属性,返回与该元素相关联的{{domxref("HTMLSlotElement")}} .</span></p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox">var <em>htmlSlotElement</em> = text.assignedSlot</pre>
+
+<h3 id="Value">Value</h3>
+
+<p>一个 {{domxref("HTMLSlotElement")}} 对象.</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('DOM WHATWG','#dom-slotable-assignedslot','assignedSlot')}}</td>
+ <td>{{Spec2('DOM WHATWG')}}</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>Basic support</td>
+ <td>{{CompatChrome(53.0)}}</td>
+ <td>{{CompatUnknown}}</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>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>{{CompatChrome(53.0)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatChrome(53.0)}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
diff --git a/files/zh-cn/web/api/text/index.html b/files/zh-cn/web/api/text/index.html
new file mode 100644
index 0000000000..53f9e6ad5a
--- /dev/null
+++ b/files/zh-cn/web/api/text/index.html
@@ -0,0 +1,195 @@
+---
+title: Text
+slug: Web/API/Text
+translation_of: Web/API/Text
+---
+<p>{{ ApiRef() }}</p>
+<p>The <strong><code>Text</code></strong> interface represents the textual content of {{domxref("Element")}} or {{domxref("Attr")}}.  If an element has no markup within its content, it has a single child implementing <code>Text</code> that contains the element's text.  However, if the element contains markup, it is parsed into information items and <code>Text</code> nodes that form its children.</p>
+<p>New documents have a single <code>Text</code> node for each block of text. Over time, more <code>Text</code> nodes may be created as the document's content changes.  The {{domxref("Node.normalize()")}} method merges adjacent <code>Text</code> objects back into a single node for each block of text.</p>
+<h2 id="Properties" name="Properties">属性</h2>
+<dl>
+ <dt>
+ {{domxref("Text.isElementContentWhitespace")}} {{readonlyInline}}{{ obsolete_inline() }}</dt>
+ <dd>
+ <p>Returns a {{domxref("Boolean")}} flag indicatingwhether or not the text node contains only whitespace.</p>
+ </dd>
+ <dt>
+ {{domxref("Text.wholeText")}} {{readonlyInline}}</dt>
+ <dd>
+ Returns a {{domxref("DOMString")}} containing the text of all <code>Text</code> nodes logically adjacent to this {{domxref("Node")}}, concatenated in document order.</dd>
+</dl>
+<h2 id="Methods" name="Methods">构造函数</h2>
+<dl>
+ <dt>
+ {{domxref("Text.Text", "Text()")}} {{experimental_inline}}</dt>
+ <dd>
+ Returns a <code>Text</code> node with the parameter as its textual content.</dd>
+</dl>
+<h2 id="Methods" name="Methods">方法</h2>
+<dl>
+ <dt>
+ {{domxref("Text.replaceWholeText")}} {{ obsolete_inline() }}</dt>
+ <dd>
+ Replaces the text of the current node and all logically adjacent nodes with the specified text.</dd>
+</dl>
+<dl>
+ <dt>
+ <span class="internal">{{domxref("Text.splitText")}}</span></dt>
+ <dd>
+ Breaks the node into two nodes at a specified offset.</dd>
+</dl>
+<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', '#text', 'Text')}}</td>
+ <td>{{Spec2('DOM WHATWG')}}</td>
+ <td>Removed the <code>isElementContentWhitespace</code> property.<br>
+ Removed the <code>replaceWholeText()</code> method.<br>
+ Added the <code>Text()</code> constructor.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM3 Core', 'core.html#ID-1312295772', 'Text')}}</td>
+ <td>{{Spec2('DOM3 Core')}}</td>
+ <td>Added the <code>isElementContentWhitespace</code> and <code>wholeText</code> properties.<br>
+ Added the <code>replaceWholeText()</code> method.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM2 Core', 'core.html#ID-1312295772', 'Text')}}</td>
+ <td>{{Spec2('DOM2 Core')}}</td>
+ <td>No change from {{SpecName('DOM1')}}.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM1', 'level-one-core.html#ID-1312295772', 'Text')}}</td>
+ <td>{{Spec2('DOM1')}}</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.0 [3]</td>
+ <td>{{CompatGeckoDesktop("1.0")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}} [3]</td>
+ <td>{{CompatVersionUnknown}} [4]</td>
+ </tr>
+ <tr>
+ <td><code>wholeText</code></td>
+ <td>1.0</td>
+ <td>{{CompatGeckoDesktop("1.9.1")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>isElementContentWhitespace</code></td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}<br>
+ Removed in {{CompatGeckoDesktop("10")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ </tr>
+ <tr>
+ <td><code>replaceWholeText</code></td>
+ <td>{{CompatVersionUnknown}} [1] [2]</td>
+ <td>{{CompatGeckoDesktop("1.9.1")}}<br>
+ Removed in {{CompatGeckoDesktop("10")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}} [1] [2]</td>
+ <td>{{CompatVersionUnknown}} [4]</td>
+ </tr>
+ <tr>
+ <td><code>Text()</code> constructor</td>
+ <td>28.0</td>
+ <td>{{CompatGeckoDesktop("24.0")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>15.0</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>{{CompatVersionUnknown}} [3]</td>
+ <td>{{CompatGeckoMobile("1.0")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}} [3]</td>
+ <td>{{CompatVersionUnknown}} [4]</td>
+ </tr>
+ <tr>
+ <td><code>wholeText</code></td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoMobile("1.9.1")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>isElementContentWhitespace</code></td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}<br>
+ Removed in {{CompatGeckoMobile("10")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ </tr>
+ <tr>
+ <td><code>replaceWholeText</code></td>
+ <td>{{CompatVersionUnknown}} [1] [2]</td>
+ <td>{{CompatGeckoMobile("1.9.1")}}<br>
+ Removed in {{CompatGeckoMobile("10")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}} [1] [2]</td>
+ <td>{{CompatVersionUnknown}} [4]</td>
+ </tr>
+ <tr>
+ <td><code>Text()</code> constructor</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoMobile("24.0")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>15.0</td>
+ <td>{{CompatNo}}</td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+<p>[1] Chromium is currently considering dropping its support.</p>
+<p>[2] Before Chrome 30 and Opera 17, the argument wasn't mandatory, like required by the specification.</p>
+<p>[3] Before Chrome 30 and Opera 17, <code>splitText()</code> argument was not mandatory, as required by the specification and implemented by IE and Gecko-based browsers.</p>
+<p>[4] The argument is not mandatory, though required by the spec.</p>
+<h2 id="相关链接">相关链接</h2>
+<ul>
+ <li><a href="/en-US/docs/DOM/DOM_Reference" title="/en-US/docs/DOM/DOM_Reference">The DOM interfaces index</a>.</li>
+</ul>
diff --git a/files/zh-cn/web/api/text/iselementcontentwhitespace/index.html b/files/zh-cn/web/api/text/iselementcontentwhitespace/index.html
new file mode 100644
index 0000000000..d138ce0a59
--- /dev/null
+++ b/files/zh-cn/web/api/text/iselementcontentwhitespace/index.html
@@ -0,0 +1,29 @@
+---
+title: Text.isElementContentWhitespace
+slug: Web/API/Text/isElementContentWhitespace
+translation_of: Web/API/Text/isElementContentWhitespace
+---
+<p>{{ ApiRef() }}</p>
+<p>{{ obsolete_header("") }}</p>
+<p>返回一个布尔值,表明该文本节点的内容是否全部是由空白符组成的.</p>
+<div class="warning">
+ <strong>警告: </strong>该属性已经在DOM level 4中被废弃, 在一些新版本的浏览器(Gecko 10.0 )中已经被删除.</div>
+<h3 id="Syntax" name="Syntax">语法</h3>
+<pre class="eval"><em>b</em> = textnode.isElementContentWhitespace;
+</pre>
+<h3 id="Example" name="Example">例子</h3>
+<p>下例中 ,我们创建了一个内容为空白符和文字组成的文本节点.该节点的isElementContentWhitespace属性为false.</p>
+<pre class="brush: js">var tn = document.createTextNode("Hello world");
+tn.isElementContentWhitespace; /* 返回false */
+</pre>
+<p>下例中 ,我们创建了一个内容全部为空白符的文本节点.该节点的isElementContentWhitespace属性为true.</p>
+<pre class="brush: js">var ws = document.createTextNode(" \t \r\n ")
+ws.isElementContentWhitespace; /* 返回true */
+</pre>
+<h3 id="Specification" name="Specification">规范</h3>
+<p><a class="external" href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#Text3-isElementContentWhitespace" title="http://www.w3.org/TR/DOM-Level-3-Core/core.html#Text3-isElementContentWhitespace">DOM Level 3 Core: Text.isElementContentWhitespace</a></p>
+<h3 id="相关链接">相关链接</h3>
+<ul>
+ <li><a class="internal" href="/zh-cn/DOM/Text" title="zh-cn/DOM/Text"><code>Text</code></a></li>
+</ul>
+<p>{{ languages( { "en": "en/DOM/Text.isElementContentWhitespace" } ) }}</p>
diff --git a/files/zh-cn/web/api/text/replacewholetext/index.html b/files/zh-cn/web/api/text/replacewholetext/index.html
new file mode 100644
index 0000000000..2cfc234e76
--- /dev/null
+++ b/files/zh-cn/web/api/text/replacewholetext/index.html
@@ -0,0 +1,36 @@
+---
+title: text.replaceWholeText
+slug: Web/API/Text/replaceWholeText
+translation_of: Web/API/Text/replaceWholeText
+---
+<p>{{ ApiRef() }}</p>
+<p>{{ Obsolete_header() }}</p>
+<p>{{ gecko_minversion_header("1.9.1") }}</p>
+<h3 id="Summary" name="Summary">Summary</h3>
+<p><strong>replaceWholeText</strong> replaces the text of the node and all of its logically adjacent text nodes with the specified text.  The replaced nodes are removed, including the current node, unless it was the recipient of the replacement text.</p>
+<div class="warning">
+ <strong>Warning:</strong> This method has been deprecated in DOM level 4 and is no longer implemented in recent browsers, including Gecko 10.0 {{ geckoRelease("10.0") }}.</div>
+<h3 id="Syntax" name="Syntax">Syntax</h3>
+<pre class="eval"><em>replacementNode</em> = textnode.replaceWholeText(content)
+</pre>
+<h3 id="Parameters" name="Parameters">Parameters</h3>
+<ul>
+ <li><code>replacementNode</code> is a <a class="internal" href="/zh-cn/DOM/Text" title="zh-cn/DOM/Text"><code>Text</code></a> node.</li>
+ <li><code>content</code> is a string specifying the text with which to replace the node's current contents.</li>
+</ul>
+<h3 id="Example" name="Example">Exceptions</h3>
+<p><strong>NO_MODIFICATION_ALLOWED_ERR</strong> : A <code>DOMException</code> thrown if one of the text nodes being replaced is read only.</p>
+<h3 id="Example" name="Example">Example</h3>
+<p>See the example for the <code><a class="internal" href="/zh-cn/DOM/Text.wholeText" title="zh-cn/DOM/Text.wholeText">text.wholeText</a></code> property.</p>
+<h3 id="Notes" name="Notes">Notes</h3>
+<p>This method returns the text node which received the replacement text, or <code>null</code> if the replacement text is an empty string.  The returned node is the current node unless the current node is read only, in which case the returned node is a newly created text node of the same type which has been inserted at the location of the replacement.</p>
+<div class="note">
+ <strong>Note:</strong> Firefox's implementation of this method does not yet support <code>EntityReference</code> nodes as defined by the <a class="external" href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-1312295772" title="http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-1312295772">specification</a>.</div>
+<h3 id="Specification" name="Specification">Specification</h3>
+<p><a class="external" href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#Text3-replaceWholeText" title="http://www.w3.org/TR/DOM-Level-3-Core/core.html#Text3-replaceWholeText">replaceWholeText </a></p>
+<h3 id="See_also">See also</h3>
+<ul>
+ <li><code><a class="internal" href="/zh-cn/DOM/Text.wholeText" title="zh-cn/DOM/Text.wholeText">text.wholeText</a></code></li>
+ <li><a class="internal" href="/zh-cn/DOM/Text" title="zh-cn/DOM/Text"><code>Text</code></a></li>
+</ul>
+<p>{{ languages( {"en": "en/DOM/text.replaceWholeText" } ) }}</p>
diff --git a/files/zh-cn/web/api/text/splittext/index.html b/files/zh-cn/web/api/text/splittext/index.html
new file mode 100644
index 0000000000..4ad321bf85
--- /dev/null
+++ b/files/zh-cn/web/api/text/splittext/index.html
@@ -0,0 +1,127 @@
+---
+title: Text.splitText()
+slug: Web/API/Text/splitText
+tags:
+ - API
+ - DOM
+ - Text
+ - 方法
+translation_of: Web/API/Text/splitText
+---
+<div>{{apiref("DOM")}}</div>
+
+<p><strong><code>Text.splitText()</code></strong> 方法可以根据指定的偏移量将一个 {{domxref("Text")}} 节点分割成前后两个独立的兄弟节点。</p>
+
+<p>如果指定的偏移量刚好等于原文本节点所包含字符串的长度,则返回一个内容为空的文本节点.</p>
+
+<p>分割后的文本节点还可以使用<a href="/zh-CN/docs/DOM/Node.normalize" title="DOM/Node.normalize"><code>Node.normalize</code></a>方法来合并.</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><em>newNode</em> = <em>textNode</em>.splitText(<em>offset</em>)
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>offset</code></dt>
+ <dd>在中断文本节点前的索引。</dd>
+</dl>
+
+<ul>
+</ul>
+
+<h3 id="返回值">返回值</h3>
+
+<p>返回一个新创建的 {{domxref("Text")}} 节点,该节点包含了 the text after the specified offset point.</p>
+
+<h3 id="异常">异常</h3>
+
+<dl>
+ <dt>INDEX_SIZE_ERR</dt>
+ <dd>如果指定的偏移量小于0或者大于原文本节点中所包含字符串的长度,则抛出这个异常.</dd>
+ <dt>NO_MODIFICATION_ALLOWED_ERR</dt>
+ <dd>如果,原文本节点只读,则抛出这个异常.</dd>
+</dl>
+
+<h2 id="Example" name="Example">例子</h2>
+
+<p>下面的例子中,一个 <code>&lt;p&gt;</code> 元素所包含的文本节点将会被分割成两个文本节点,然后在这两个节点中间插入一个 <code>&lt;span&gt;</code> 元素。</p>
+
+<h3 id="HTML">HTML</h3>
+
+<pre class="brush:html"> &lt;p id="p"&gt;foobar&lt;/p&gt;
+</pre>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<pre class="brush: js">const p = document.getElementById('p');
+
+// 将 &lt;p&gt; 的内容读取为一个文本节点
+const foobar = p.firstChild;
+
+// 将原来的文本节点分割成为内容分别为 foo 和 bar 的两个文本节点
+const bar = foobar.splitText(3);
+
+// 创建一个包含了内容为 ' new content ' 的文本节点的 &lt;u&gt; 元素
+const u = document.createElement('u');
+u.appendChild(document.createTextNode(' new content '));
+
+// 将 &lt;u&gt; 元素插入到后一个文本节点 'bar' 的前面
+p.insertBefore(u, bar);
+
+// 现在,HTML 结构就变成了 &lt;p id="p"&gt;foo &lt;span&gt;span contents&lt;/span&gt; bar&lt;/p&gt;
+</pre>
+
+<h3 id="结果">结果</h3>
+
+<p>{{EmbedLiveSample("Example", 700, 70)}}</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-text-splittext', 'Text.splitText')}}</td>
+ <td>{{Spec2('DOM WHATWG')}}</td>
+ <td>No change from {{SpecName('DOM3 Core')}}.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM3 Core', 'core.html#ID-38853C1D', 'Text.splitText')}}</td>
+ <td>{{Spec2('DOM3 Core')}}</td>
+ <td>No change from {{SpecName('DOM2 Core')}}.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM2 Core', 'core.html#ID-38853C1D', 'Text.splitText')}}</td>
+ <td>{{Spec2('DOM2 Core')}}</td>
+ <td>No change from {{SpecName('DOM1')}}.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM1', 'level-one-core.html#ID-38853C1D', 'Text.splitText')}}</td>
+ <td>{{Spec2('DOM1')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.Text.splitText")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>The {{domxref("Text")}} interface it belongs to.</li>
+ <li>The opposite method: {{domxref("Node.normalize")}}.</li>
+</ul>
+
+<div id="gtx-trans" style="position: absolute; left: 48px; top: 508px;">
+<div class="gtx-trans-icon"></div>
+</div>
diff --git a/files/zh-cn/web/api/text/text/index.html b/files/zh-cn/web/api/text/text/index.html
new file mode 100644
index 0000000000..dee1c9a948
--- /dev/null
+++ b/files/zh-cn/web/api/text/text/index.html
@@ -0,0 +1,96 @@
+---
+title: Text()
+slug: Web/API/Text/Text
+tags:
+ - API
+ - Text
+translation_of: Web/API/Text/Text
+---
+<p>{{ Apiref("DOM")}}{{seeCompatTable}}</p>
+
+<p><code><strong> Text()</strong></code> 构造方法返回一个最新创建的{{domxref("Text")}} 对象,该对象带有可选参数 {{domxref("DOMString")}} 作为文本节点的文本内容(textual content)。</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox"><em>text1</em> = new Text(); // 创建一个空的文本节点(text node),即它的textContent 为空字符
+<em>text2</em> = new Text("This is a text node");//该构造方法参数作为文本节点的textContent 的值。
+</pre>
+
+<h2 id="Example">Example</h2>
+
+<pre class="brush: js"><code class="language-js">text <span class="operator token">=</span> new Text<span class="function token"><span class="punctuation token">("Test"</span></span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+
+<h2 id="Specification" name="Specification">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('DOM WHATWG', '#text', 'Text.Text()')}}</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>28.0</td>
+ <td>{{CompatGeckoDesktop("24.0")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>15.0</td>
+ <td>8.0</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>{{CompatGeckoMobile("24.0")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>15.0</td>
+ <td>8.0</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/DOM/DOM_Reference" title="/en-US/docs/DOM/DOM_Reference">The DOM interfaces index.</a></li>
+</ul>
+
+<p> </p>
diff --git a/files/zh-cn/web/api/text/wholetext/index.html b/files/zh-cn/web/api/text/wholetext/index.html
new file mode 100644
index 0000000000..5ec686a5b9
--- /dev/null
+++ b/files/zh-cn/web/api/text/wholetext/index.html
@@ -0,0 +1,141 @@
+---
+title: Text.wholeText
+slug: Web/API/Text/wholeText
+translation_of: Web/API/Text/wholeText
+---
+<p>{{ apiref("DOM") }}</p>
+
+<p><font><font>该</font></font><strong><code>Text.wholeText</code></strong><font><font>只读属性返回</font></font><a href="https://developer.mozilla.org/en-US/docs/Web/API/Text" title="文本界面表示元素或属性的文本内容。 如果一个元素在其内容中没有标记,则它有一个实现包含元素文本的Text的单个子元素。 但是,如果元素包含标记,则将其解析为形成子元素的信息项和文本节点。"><code>Text</code></a><font><font>逻辑上相邻的节点的所有文本。</font></font><font><font>文本按文档顺序连接。</font><font>这允许指定任何文本节点并获取所有相邻文本作为单个字符串。</font></font></p>
+
+<h2 id="Syntax" name="Syntax">Syntax</h2>
+
+<pre class="syntaxbox notranslate"><em>str</em> = <em>textnode</em>.wholeText;</pre>
+
+<h2 id="Example" name="Example">Notes and example</h2>
+
+<p>假设你的网页上有如下的简单文本(包括其中为了格式化代码而添加的一些空格), 其 DOM 节点 被储存在变量 <code>para</code> 中:</p>
+
+<pre class="brush: html notranslate">&lt;p&gt;Thru-hiking is great! &lt;strong&gt;No insipid election coverage!&lt;/strong&gt;
+ However, &lt;a href="http://en.wikipedia.org/wiki/Absentee_ballot"&gt;casting a
+ ballot&lt;/a&gt; is tricky.&lt;/p&gt;
+</pre>
+
+<p>你觉得你不喜欢中间的句子, 所以你移除了它:</p>
+
+<pre class="brush: js notranslate">para.removeChild(para.childNodes[1]);
+</pre>
+
+<p>过了一会, 你又决定给“Thru-hiking is great, but casting a ballot is tricky.”这句换个说法, <em>同时保留超链接</em>。 所以你尝试以下代码:</p>
+
+<pre class="brush: js notranslate">para.firstChild.data = "Thru-hiking is great, but ";
+</pre>
+
+<p>一切妥当, 是么? <em>不!</em> 这会使你移除 <code>strong</code> 元素, 而被删掉的句子分隔了两个文本节点. 一个是第一句, 一个是最后一个单词. 相反, 你现在获得如下效果:</p>
+
+<pre class="brush: html notranslate">&lt;p&gt;Thru-hiking is great, but However, &lt;a
+ href="http://en.wikipedia.org/wiki/Absentee_ballot"&gt;casting a
+ ballot&lt;/a&gt; is tricky.&lt;/p&gt;
+</pre>
+
+<p>实际上,你更倾向于将这些相邻扽文本节点作为同一文本节点. 这就是 <code>wholeText</code> 的用武之地:如果你有许多相邻的文本节点, 你可以通过<code>wholeText</code>访问这些节点里的所有内容。让我们假设你从未犯过最后一个错误. 在这种情况下, 我们有:</p>
+
+<pre class="brush: js notranslate">assert(para.firstChild.wholeText == "Thru-hiking is great! However, ");
+</pre>
+
+<p><code>wholeText</code> 只是文本节点的一个属性,特可以返回连接了所有相邻(i.e. 没有被其它元素边界分开) 文本节点数据的字符串 。</p>
+
+<p>现在让我们回到最初的问题. 我们想做的是用新的文本替代旧的文本. 这就是 {{domxref("Text.replaceWholeText", "replaceWholeText()")}} 用处所在:</p>
+
+<pre class="brush: js notranslate">para.firstChild.replaceWholeText("Thru-hiking is great, but ");
+</pre>
+
+<p>我们移除了所有的相邻文本节点 (所有构成whole text的文本节点) 除了调用<code>replaceWholeText()</code> 的,并且把剩余的文本改成了新文本. 我们现在所得到的是这样的:</p>
+
+<pre class="brush: html notranslate">&lt;p&gt;Thru-hiking is great, but &lt;a
+ href="http://en.wikipedia.org/wiki/Absentee_ballot"&gt;casting a
+ ballot&lt;/a&gt; is tricky.&lt;/p&gt;
+</pre>
+
+<p>有时候使用whole-text 功能同时使用<code>Node.textContent</code> 或长期支持的 {{domxref("Element.innerHTML")}}; 可以得到更好的处理。如果你需要处理一个元素内的混合内容, 正如本文所介绍的, <code>wholeText</code> 和 <span class="internal"><code>replaceWholeText()</code></span> 是有用的。</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('DOM WHATWG', '#dom-text-wholetext', 'Text.wholeText')}}</td>
+ <td>{{Spec2('DOM WHATWG')}}</td>
+ <td>No significant change.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM3 Core', 'core.html#Text3-wholeText', 'Text.wholeText')}}</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>Edge</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>1.0</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoDesktop("1.9.1")}}</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>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>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoMobile("1.9.1")}}</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("Text")}} interface it belongs to.</li>
+</ul>