Range.detach

  • Revision slug: DOM/range.detach
  • Revision title: range.detach
  • Revision id: 14149
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment note this is a no-op in Gecko 15+, per bug 702948; 157 words added, 32 words removed

Revision Content

{{ DomRef() }}

Summary

Releases a Range from use to improve performance. This lets the browser choose to release resources associated with this Range. Subsequent attempts to use the detached range will result in a DOMException being thrown with an error code of INVALID_STATE_ERR.

Syntax

range.detach();

Example

range = document.createRange();
range.selectNode(document.getElementsByTagName("div").item(0));
range.detach();

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }}

Gecko notes

Starting in Gecko 15.0 {{ geckoRelease("15.0") }}, this method is a no-op and has no effect.

Specification

{{ spec("http://www.w3.org/TR/dom/#dom-range-detach", "DOM4: Range.detach") }}

Revision Source

<p>{{ DomRef() }}</p>
<h3 id="Summary" name="Summary">Summary</h3>
<p>Releases a <code>Range</code> from use to improve performance. This lets the browser choose to release resources associated with this <code>Range</code>. Subsequent attempts to use the detached range will result in a <code>DOMException</code> being thrown with an error code of <code>INVALID_STATE_ERR</code>.</p>
<h3 id="Syntax" name="Syntax">Syntax</h3>
<pre class="eval">range.detach();
</pre>
<h3 id="Example" name="Example">Example</h3>
<pre class="eval">range = document.createRange();
range.selectNode(document.getElementsByTagName("div").item(0));
range.detach();
</pre>
<h3 id="Notes" name="Notes">Browser compatibility</h3>
<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>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</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>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>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> </tr> </tbody> </table>
</div>
<h4 id="Gecko_notes">Gecko notes</h4>
<p>Starting in Gecko 15.0 {{ geckoRelease("15.0") }}, this method is a no-op and has no effect.</p>
<h3 id="Specification" name="Specification">Specification</h3>
<p>{{ spec("http://www.w3.org/TR/dom/#dom-range-detach", "DOM4: Range.detach") }}</p>
Revert to this revision