blob: 5ffd11b79e4d69cfbdeef500e4110e6ac662f808 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
---
title: range.intersectsNode
slug: Web/API/Range/intersectsNode
tags:
- Referencia_DOM_de_Gecko
translation_of: Web/API/Range/intersectsNode
---
<p>{{ ApiRef() }}</p>
<h3 id="Summary" name="Summary">Summary</h3>
<p>{{ Obsolete_header() }} Returns a boolean indicating whether the given node intersects the range.</p>
<h3 id="Syntax" name="Syntax">Syntax</h3>
<pre class="eval">bool = range.intersectsNode( referenceNode )
</pre>
<h3 id="Parameters" name="Parameters">Parameters</h3>
<dl>
<dt>
referenceNode </dt>
<dd>
The <code>Node</code> to compare with the <code>Range</code>.</dd>
</dl>
<h3 id="Example" name="Example">Example</h3>
<pre class="eval">range = document.createRange();
range.selectNode(document.getElementsByTagName("div").item(0));
bool = range.intersectsNode(document.getElementsByTagName("p").item(0));
</pre>
<h3 id="Notes" name="Notes">Notes</h3>
<p>This method is obsolete; you should instead use the W3C DOM Range methods (see <code><a href="es/DOM/range.compareBoundaryPoints">compareBoundaryPoints()</a></code>).</p>
<div class="warning">
<b>Warning:</b> This method <a href="es/Gecko_1.9_Changes_affecting_websites">has been removed</a> from <a href="es/Gecko">Gecko</a> 1.9 and will not exist in future versions of Firefox; you should switch to <code>compareBoundaryPoints()</code> as soon as possible.</div>
<p>The following function can be used as replacement:</p>
<pre class="eval">function rangeIntersectsNode(range, node) {
var nodeRange = node.ownerDocument.createRange();
try {
nodeRange.selectNode(node);
}
catch (e) {
nodeRange.selectNodeContents(node);
}
return range.compareBoundaryPoints(Range.END_TO_START, nodeRange) == -1 &&
range.compareBoundaryPoints(Range.START_TO_END, nodeRange) == 1;
}
</pre>
<h3 id="Specification" name="Specification">Specification</h3>
<p>This method is not part of a specification.</p>
<div class="noinclude">
</div>
<p>{{ languages( { "en": "en/DOM/range.intersectsNode", "pl": "pl/DOM/range.intersectsNode" } ) }}</p>
|