diff options
Diffstat (limited to 'files/zh-cn/web/api/text/index.html')
-rw-r--r-- | files/zh-cn/web/api/text/index.html | 195 |
1 files changed, 195 insertions, 0 deletions
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> |