DOM:range.compareBoundaryPoints
From MDC
Contents |
[edit] Summary
Compares the boundary points of two Ranges.
[edit] Syntax
compare = range.compareBoundaryPoints(how, sourceRange);
- compare
- A number, -1, 0, or 1, indicating whether the corresponding boundary-point of range is respectively before, equal to, or after the corresponding boundary-point of
sourceRange. - how
- A constant describing the comparison method, one of values described below.
- sourceRange
- A Range to compare boundary points with range
[edit] Example
var range, sourceRange, compare;
range = document.createRange();
range.selectNode(document.getElementsByTagName("div")[0]);
sourceRange = document.createRange();
sourceRange.selectNode(document.getElementsByTagName("div")[1]);
compare = range.compareBoundaryPoints(Range.START_TO_END, sourceRange);
[edit] Notes
Any of the following constants can be passed as the value of how parameter:
-
Range.END_TO_ENDcompares the end boundary-point ofsourceRangeto the end boundary-point ofrange. -
Range.END_TO_STARTcompares the end boundary-point ofsourceRangeto the start boundary-point ofrange. -
Range.START_TO_ENDcompares the start boundary-point ofsourceRangeto the end boundary-point ofrange. -
Range.START_TO_STARTcompares the start boundary-point ofsourceRangeto the start boundary-point ofrange.