Javascript Reference
Categories: Range

javascript Range comparePoint( )

@March 15, 2008, 1:22 a.m.
comparePoint( )Firefox/Netscape/NN 6 IE n/a Chrome/Safari/DOM n/a  

compareNode(nodeReference, offset)

  

A Netscape-only method that returns an integer code indicating the relative position of some other node and offset within that node with respect to the current range. Note that the returned values are from the point of view of the node (more specifically, the point signified by the offset within the node) passed as parameters, rather than from that of the current range.

 

Returned values are as follows.

 
ValueDescription
-1Point comes before the start of the range.
0Point is located within the range.
1Point comes after the end of the range.
 

By way of example:

if (rng.comparePoint(document.getElementById("myElem"), 2) == 0) {
    // process for offset of 2 within myElem node being contained by the range
}
 
Parameters
 
  • Reference to any node in the document tree.
  • Integer offset, counting either nested nodes within an element or characters within a text node.
 
Returned Value

Integer values -1, 0, 1.


Powered by Linode.