Text.replaceWholeText

  • Revision slug: DOM/Text.replaceWholeText
  • Revision title: Text.replaceWholeText
  • Revision id: 65288
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment 17 words added

Revision Content

{{ DomRef() }}

{{ fx_minversion_header("3") }}

Summary

replaceWholeText 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.

Syntax

replacementNode = textnode.replaceWholeText(content) 

Parameters

  • replacementNode is a Text node.
  • content is a string specifying the text with which to replace the node's current contents.

Exceptions

 

 

NO_MODIFICATION_ALLOWED_ERR
A DOMException thrown if one of the text nodes being replaced is read only.

 

Example

See the example for the text.wholeText property.

Notes

This method returns the text node which received the replacement text, or null 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.

Note: Firefox's implementation of this method does not yet support EntityReference nodes as defined by the specification.

Specification

replaceWholeText  

Revision Source

<p>{{ DomRef() }}</p>
<p>{{ fx_minversion_header("3") }}</p>
<h3 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>
<h3 name="Syntax">Syntax</h3>
<pre class="eval"><em>replacementNode</em> = textnode.replaceWholeText(content) 
</pre>
<h3 name="Parameters">Parameters</h3>
<ul> <li><code>replacementNode</code> is a <a class="internal" href="/En/DOM/Text" title="En/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 name="Example">Exceptions</h3>
<p> </p>
<p> </p><dt>NO_MODIFICATION_ALLOWED_ERR</dt><dd>A <code>DOMException</code> thrown if one of the text nodes being replaced is read only.</dd>
<p> </p>
<h3 name="Example">Example</h3>
<p>See the example for the <code><a class="internal" href="/En/DOM/Text.wholeText" title="En/DOM/Text.wholeText">text.wholeText</a></code> property.</p>
<h3 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 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>
Revert to this revision