Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

range.intersectsNode

Summary

Obsoleto
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

Returns a boolean indicating whether the given node intersects the range.

Syntax

bool = range.intersectsNode( referenceNode )

Parameters

referenceNode 
The Node to compare with the Range.

Example

range = document.createRange();
range.selectNode(document.getElementsByTagName("div").item(0));
bool = range.intersectsNode(document.getElementsByTagName("p").item(0));

Notes

This method is obsolete; you should instead use the W3C DOM Range methods (see compareBoundaryPoints()).

Warning: This method has been removed from Gecko 1.9 and will not exist in future versions of Firefox; you should switch to compareBoundaryPoints() as soon as possible.

The following function can be used as replacement:

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;
}

Specification

This method is not part of a specification.

 

Etiquetas y colaboradores del documento

 Colaboradores en esta página: fscholz, khalid32, Mgjbot, DR
 Última actualización por: khalid32,