mozilla

Revision 453945 of CharacterData

  • Revision slug: Web/API/CharacterData
  • Revision title: CharacterData
  • Revision id: 453945
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment
Tags: 

Revision Content

{{DOMRef}}

The CharacterData abstract interface represents {{domxref("Node")}} that contains characters. This is an abstract interface, meaning there aren't object of type CharacterData, that is implemented by other interfaces, like {{domxref("Text")}}, {{domxref("Comment")}}, or {{domxref("ProcessingInstruction")}}

Properties

Inherits properties from its parent, {{domxref("Node")}}, and implements the {{domxref("ChildNode")}} interface.

{{domxref("CharacterData.data")}}
Is a {{domxref("DOMString")}} representing the textual data contained in this object.
{{domxref("CharacterData.length")}} {{readonlyInline}}
Returns an unsigned long representing the size of the string contained in CharacterData.data.
{{domxref("ChildNode.nextElementSibling")}} {{readonlyInline}}
Returns the {{domxref("Element")}} immediately following the specified one in its parent's children list, or null if the specified element is the first one in the list.
{{domxref("ChildNode.previousElementSibling")}} {{readonlyInline}}
Returns the {{domxref("Element")}} immediately prior to the specified one in its parent's children list, or null if the specified element is the first one in the list.

Methods

Inherits methods from its parent, {{domxref("Node")}}, and implements the {{domxref("ChildNode")}} interface.

{{domxref("CharacterData.appendData")}}
Appends the given {{domxref("DOMString")}} to the CharacterData.data string; when this method returns, data contains the concatenated {{domxref("DOMString")}}.
{{domxref("CharacterData.deleteData")}}
Removes the specified amount of characters, starting at the specified offset, from the CharacterData.data string; when this method returns, data contains the shortened {{domxref("DOMString")}}.
{{domxref("CharacterData.insertData")}}
Inserts the specified characters, at the specified offset, in the CharacterData.data string; when this method returns, data contains the modified {{domxref("DOMString")}}.
{{domxref("ChildNode.remove")}} {{experimental_inline}}
Removes the object from its parent children list.
{{domxref("CharacterData.replaceData")}}
Replaces the specified amount of characters, starting at the specified offset, with the specified {{domxref("DOMString")}}; when this method returns, data contains the modified {{domxref("DOMString")}}.
{{domxref("CharacterData.substringData")}}
Returns a {{domxref("DOMString")}} containing the part of CharacterData.data of the specified length and starting at the specified offset.

Specifications

Specification Status Comment
{{SpecName('DOM WHATWG', '#characterdata', 'CharacterData')}} {{Spec2('DOM WHATWG')}} Added implemention of the {{domxref("ChildNode")}} interface
{{SpecName('DOM3 Core', 'core.html#ID-FF21A306', 'CharacterData')}} {{Spec2('DOM3 Core')}} No change from {{SpecName('DOM2 Core')}}
{{SpecName('DOM2 Core', 'core.html#ID-FF21A306', 'CharacterData')}} {{Spec2('DOM2 Core')}} No change from {{SpecName('DOM1')}}
{{SpecName('DOM1', 'level-one-core.html#ID-FF21A306', 'CharacterData')}} {{Spec2('DOM1')}} Initial definition

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 {{CompatGeckoDesktop("1.0")}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
Implements {{domxref("ChildNode")}} interface. {{CompatUnknown}} {{CompatGeckoDesktop("25.0")}} {{CompatNo}} {{CompatUnknown}} {{CompatNo}}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}} {{CompatGeckoMobile("1.0")}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
Implements {{domxref("ChildNode")}} interface. {{CompatUnknown}} {{CompatGeckoMobile("25.0")}} {{CompatNo}} {{CompatUnknown}} {{CompatNo}}

See also

Revision Source

<p>{{DOMRef}}</p>
<p>The <code><strong>CharacterData</strong></code> abstract interface represents {{domxref("Node")}} that contains characters. This is an abstract interface, meaning there aren't object of type <code>CharacterData</code>, that is implemented by other interfaces, like {{domxref("Text")}}, {{domxref("Comment")}}, or {{domxref("ProcessingInstruction")}}</p>
<h2 id="Properties">Properties</h2>
<p><em>Inherits properties from its parent, {{domxref("Node")}}, and implements the {{domxref("ChildNode")}} interface.</em></p>
<dl>
  <dt>
    {{domxref("CharacterData.data")}}</dt>
  <dd>
    Is a {{domxref("DOMString")}} representing the textual data contained in this object.</dd>
  <dt>
    {{domxref("CharacterData.length")}} {{readonlyInline}}</dt>
  <dd>
    Returns an <code>unsigned long</code> representing the size of the string contained in <code>CharacterData.data</code>.</dd>
  <dt>
    {{domxref("ChildNode.nextElementSibling")}} {{readonlyInline}}</dt>
  <dd>
    Returns the {{domxref("Element")}} immediately following the specified one in its parent's children list, or <code>null</code> if the specified element is the first one in the list.</dd>
  <dt>
    {{domxref("ChildNode.previousElementSibling")}} {{readonlyInline}}</dt>
  <dd>
    Returns the {{domxref("Element")}} immediately prior to the specified one in its parent's children list, or <code>null</code> if the specified element is the first one in the list.</dd>
</dl>
<h2 id="Methods" name="Methods">Methods</h2>
<p><em>Inherits methods from its parent, {{domxref("Node")}}, and implements the {{domxref("ChildNode")}} interface.</em></p>
<dl>
  <dt>
    {{domxref("CharacterData.appendData")}}</dt>
  <dd>
    Appends the given {{domxref("DOMString")}} to the <code>CharacterData.data</code> string; when this method returns, <code>data</code> contains the concatenated {{domxref("DOMString")}}.</dd>
  <dt>
    {{domxref("CharacterData.deleteData")}}</dt>
  <dd>
    Removes the specified amount of characters, starting at the specified offset, from the <code>CharacterData.data</code> string; when this method returns, <code>data</code> contains the shortened {{domxref("DOMString")}}.</dd>
  <dt>
    {{domxref("CharacterData.insertData")}}</dt>
  <dd>
    Inserts the specified characters, at the specified offset, in the <code>CharacterData.data</code> string; when this method returns, <code>data</code> contains the modified {{domxref("DOMString")}}.</dd>
  <dt>
    {{domxref("ChildNode.remove")}} {{experimental_inline}}</dt>
  <dd>
    Removes the object from its parent children list.</dd>
  <dt>
    {{domxref("CharacterData.replaceData")}}</dt>
  <dd>
    Replaces the specified amount of characters, starting at the specified offset, with the specified {{domxref("DOMString")}}; when this method returns, <code>data</code> contains the modified {{domxref("DOMString")}}.</dd>
  <dt>
    {{domxref("CharacterData.substringData")}}</dt>
  <dd>
    Returns a {{domxref("DOMString")}} containing the part of <code>CharacterData.data</code> of the specified length and starting at the specified offset.</dd>
</dl>
<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', '#characterdata', 'CharacterData')}}</td>
      <td>{{Spec2('DOM WHATWG')}}</td>
      <td>Added implemention of the {{domxref("ChildNode")}} interface</td>
    </tr>
    <tr>
      <td>{{SpecName('DOM3 Core', 'core.html#ID-FF21A306', 'CharacterData')}}</td>
      <td>{{Spec2('DOM3 Core')}}</td>
      <td>No change from {{SpecName('DOM2 Core')}}</td>
    </tr>
    <tr>
      <td>{{SpecName('DOM2 Core', 'core.html#ID-FF21A306', 'CharacterData')}}</td>
      <td>{{Spec2('DOM2 Core')}}</td>
      <td>No change from {{SpecName('DOM1')}}</td>
    </tr>
    <tr>
      <td>{{SpecName('DOM1', 'level-one-core.html#ID-FF21A306', 'CharacterData')}}</td>
      <td>{{Spec2('DOM1')}}</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>1.0</td>
        <td>{{CompatGeckoDesktop("1.0")}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
      </tr>
      <tr>
        <td>Implements {{domxref("ChildNode")}} interface.</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatGeckoDesktop("25.0")}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatUnknown}}</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}}</td>
        <td>{{CompatGeckoMobile("1.0")}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
      </tr>
      <tr>
        <td>Implements {{domxref("ChildNode")}} interface.</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatGeckoMobile("25.0")}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatNo}}</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>
Revert to this revision