javascript Range compareBoundaryPoints( )
compareBoundaryPoints( ) | Firefox/Netscape/NN 6 IE n/a Chrome/Safari/DOM 2 | |||||||||
compareBoundaryPoints(compareType, sourceRangeRef) | ||||||||||
Returns an integer code indicating the relative positioning of one boundary point of the current range's against a boundary point of a different text range. In the simplest case, the two end points (one from each range) share the same ancestor container. In such a case, the first parameter determines which end points from the two ranges get compared. Use the constants supplied with every Range object, as shown in the following table. |
||||||||||
If the first boundary in the comparison occurs earlier in the document than the second boundary, the returned value is -1; if the first boundary comes after the second boundary, the returned value is 1; if the two boundaries are in the identical position, the returned value is 0. Similar to the IE TextRange object's compareEndPoints( ) method. |
||||||||||
But the situation can be more complex if the boundary points being compared have different ancestor container nodes. The offset values with respect to container nodes influence the comparison results. Due to the variety of results that can occur with numerous relationships between the compared end points, your scripts will need to perform an intricate analysis of boundaries to assure comparisons report the desired sequence. On the other hand, simply looking for unanimity of boundary points is a much simpler prospect. You may prefer to limit your comparisons to looking only for return values of zero (or any other value) for a more binary determination of boundary comparisons. |
||||||||||
|
||||||||||
Parameters | ||||||||||
|
||||||||||
Returned Value | ||||||||||
Integer values -1, 0, or 1. |
Powered by Linode.