inRange
Method of dom/Elementdom/Element
Syntax
var object = object.inRange(/* see parameter list */);
Parameters
Range
- Data-type
- any
TextRange object that might be contained.
Return Value
Returns an object of type DOM NodeDOM Node
Boolean
Boolean that returns one of the following possible values.
Return value | Description |
---|---|
true | Range is contained within or is equal to the TextRange object on which the method is called. |
false | Range is not contained within the TextRange object on which the method is called. |
Examples
The following example shows how to use the inRange method to show that two TextRange objects are equal.
<html> <script type="text/javascript"> 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>
The following example shows how to use the inRange method to show that two contained ranges are not equal.
<html> <script type="text/javascript"> window.onload=fnCheck; function fnCheck(){ var oRng1 = document.body.createTextRange(); // create a text range var oRng2 = oRng1.duplicate(); // create a duplicate range base on oRng1oRng1.moveToElementText(document.getElementById("div1")); oRng2.moveToElementText(document.getElementById("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>
The following example shows how to use the inRange method to show that a text range exists within another text range.
<html> <script type="text/javascript"> 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>
Notes
Remarks
This feature might not be available on platforms other than Microsoft Win32.
Syntax
Standards information
There are no standards that apply here.
See also
Related pages
Attributions
Microsoft Developer Network: [Windows Internet Explorer API reference Article]