This example demonstrates the inRange method, a member of the TextRange object. The script behind this page creates several text ranges over various parts of the document.
It then calls the inRange method to determine if the respective text ranges are contained by one another.
Case 1
The first case defines a range ( Range 1 ) over the entire body of the document. A duplicate range is created ( Range 2 ) based on Range 1. Since Range 1 and Range 2 are identical, inRange returns true.
Case 2
The second case moves Range 1 so that it comprises division 1 below. Range 2 is moved so that it comprises division 2 below. Since division 2 is not contained within division 1, inRange returns false.
Case 3
The third case defines a range ( Range 3 ) that duplicates Range 1. It then moves the range by calling findText. Since the text to be found is contained within the range defined by Range 1, inRange returns true.