inRange Method
Returns whether one range is contained within another.
Syntax
bFound = TextRange.inRange(oRange)
Parameters
oRange Required. Object that specifies a TextRange object.
Return Value
Boolean. Returns true if the range passed as the method parameter is contained within or is equal to the range on which the method is called, or false otherwise.
Remarks
This feature might not be available on non-Win32® platforms. For the latest information about Internet Explorer cross-platform compatibility, see article q172976 in the Microsoft Knowledge Base.
Example
Sample Code
This example uses the inRange method to show that two TextRange objects are equal.
<HTML> <SCRIPT> window.onload=fnCheck; function fnCheck(){ var oRng1 = document.body.createTextRange(); var oRng2 = oRng1.duplicate(); var bInside = oRng1.inRange(oRng2); // returns true; } </SCRIPT> <BODY> <DIV ID=div1> Content for division 1. </DIV> <DIV ID=div2> Content for division 2. </DIV> </BODY> </HTML>This example uses the inRange method to show that two contained ranges are not equal.
<HTML> <SCRIPT> window.onload=fnCheck; function fnCheck(){ var oRng1.moveToElementText(div1); var oRng2.moveToElementText(div2); var bInside = oRng1.inRange(oRng2); // returns false; } </SCRIPT> <BODY> <DIV ID=div1> Content for division 1. </DIV> <DIV ID=div2> Content for division 2. </DIV> </BODY> </HTML>This example uses the inRange method to show that a text range exists within another text range.
<HTML> <SCRIPT> window.onload=fnCheck; function fnCheck(){ var oRng1 = document.body.createTextRange(); var oRng3 = oRng1.duplicate(); oRng3.findText('division 1'); var bInside = oRng1.inRange(oRng3); // returns true; } </SCRIPT> <BODY> <DIV ID=div1> Content for division 1. </DIV> <DIV ID=div2> Content for division 2. </DIV> </BODY> </HTML>
Applies To
[ Object Name ] Platform Version Win16: Win32: Mac: Unix: WinCE: Version data is listed when the mouse hovers over a link, or the link has focus.
See Also
Did you find this topic useful? Suggestions for other topics? write us!
© 1999 microsoft corporation. all rights reserved. terms of use.