diff options
Diffstat (limited to 'files/es/web/api/range/intersectsnode/index.html')
-rw-r--r-- | files/es/web/api/range/intersectsnode/index.html | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/files/es/web/api/range/intersectsnode/index.html b/files/es/web/api/range/intersectsnode/index.html new file mode 100644 index 0000000000..5ffd11b79e --- /dev/null +++ b/files/es/web/api/range/intersectsnode/index.html @@ -0,0 +1,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> |