Method | NS2 | NS3 | NS4 | NS6 | IE3a | IE3b | IE4 | IE5 | IE5.5 | IE6 |
collapse | | | | | | | x | x | x | x |
| Returns: Nothing |
| Shrinks a text range down to an insertion point. |
| Syntax: TextRange .collapse([ start ]) . Here, start can be true (the default) to move the insertion point to the beginning of the text range, or false to move the insertion point to the end of the text range. |
compareEndPoints | | | | | | | x | x | x | x |
| Returns: Integer |
| Compares an end point of a TextRange object with an end point of another range. |
| Syntax: TextRange .compareEndPoints( type , range ) , where the possible values of type are StartToEnd (compares the start of the TextRange object with the end of the range parameter), StartToStart (compares the start of the TextRange object with the start of the range parameter), EndToStart (compares the end of the TextRange object with the start of the range parameter), EndToEnd (compares the end of the TextRange object with the end of the range parameter). The range parameter holds the range to compare the current one to. Returns -1 if the comparison point in the TextRange object is further to the left than the comparison point in range , if the comparison point the TextRange object is at the same location as the comparison point in range , and 1 if the comparison point in the TextRange object is farther to the right than the comparison point in range . |
duplicate | | | | | | | x | x | x | x |
| Returns: TextRange object |
| Duplicates and returns a new copy of the text range. |
| Syntax: TextRange .duplicate() . |
execCommand | | | | | | | x | x | x | x |
| Returns: Boolean |
| This is a big onesee "Using execCommand " in Chapter 9 for the syntax and possible parameters (listed in Table 9.6) of this method. |
expand | | | | | | | x | x | x | x |
| Returns: Boolean |
| This method expands a range (even if it was not collapsed ) to the next word, character, and so on. |
| Syntax: TextRange.expand( unit ) , where unit is one of "character" (expands by a character), "word" (expands by a word), " sentence " (expands by a sentence), or "textedit" (expands to enclose the entire range). This method returns true if successful, and false otherwise . |
findText | | | | | | | x | x | x | x |
| Returns: Boolean |
| Searches a range for text. See "Finding and Replacing Text" in this chapter for the syntax and an example. |
getBookmark | | | | | | | x | x | x | x |
| Returns: Bookmark (string) |
| Gets a bookmark (a string) that you can use with the moveToBookmark method to move back to the same range. |
| Syntax: TextRange .getBookmark() . Returns a bookmark if successful, or null otherwise. |
getBoundingClientRect | See Chapter 6. |
getClientRects | See Chapter 6. |
inRange | | | | | | | x | x | x | x |
| Returns: Boolean |
| Returns a value indicating whether one range is contained within another. |
| Syntax: TextRange .inRange( range ) . Returns true if range is in (or is equal to) TextRange , false otherwise. |
isEqual | | | | | | | x | x | x | x |
| Returns: Boolean |
| Indicates whether one range is equal to another. |
| Syntax: TextRange .isEqual( range ) . Returns true if TextRange equals range . Returns false otherwise. |
move | | | | | | | x | x | x | x |
| Returns: Integer |
| Moves a range a specified number of items, such as characters , words, or sentences. |
| Syntax: TextRange .move( item [, count ]) . Here, item can be one of "character" (moves by a character), "word" (moves by a word), "sentence" (moves by a sentence), or "textedit" (moves to the start of end of the original range); and count is the number of items to move by (can be positive or negative). Returns the number of items the range was moved by. |
moveEnd | | | | | | | x | x | x | x |
| Returns: Integer |
| Moves the end of the range. |
| Syntax: TextRange .moveEnd( item [, count ]) . Here, item can be one of "character" (moves the end by a character), "word" (moves the end by a word), "sentence" (moves the end by a sentence), or "textedit" (moves to the end of the original range); and count is the number of items to move the end by (can be positive or negative). Returns the number of items the end of the range was moved by. |
moveStart | | | | | | | x | x | x | x |
| Returns: Integer |
| Moves the start of the range. |
| Syntax: TextRange .moveStart( item [, count ]) . Here, item can be one of "character" (moves the start by a character), "word" (moves the start by a word), "sentence" (moves the start by a sentence), or "textedit" (moves to the start of the original range); and count is the number of items to move the start by (can be positive or negative). Returns the number of items the start of the range was moved by. |
moveToBookmark | | | | | | | x | x | x | x |
| Returns: Boolean |
| Moves the range to a bookmark set with getBookmark . |
| Syntax: TextRange .moveToBookmark( bookmark ) , where bookmark is a string returned by getBookmark . Returns true if successful, false otherwise. |
moveToElementText | | | | | | | | x | x | x |
| Returns: Nothing |
| Moves the text range so that the start and end positions of the range surround the text in the given element. |
| Syntax: TextRange .moveToElementText( element ) , where element is the element whose text you want to enclose. |
moveToPoint | | | | | | | x | x | x | x |
| Returns: Nothing |
| Moves the start and end positions of the text range to the given point, collapsing the range to that point. |
| Syntax: TextRange .moveToPoint( x , y ) where x and y give the location of the point to move to, measured with respect to the upper left of the browser's client area, in pixels. |
parentElement | | | | | | | x | x | x | x |
| Returns: Element |
| Returns the parent element of the text range if successful, null otherwise. |
| Syntax: TextRange .parentElement() . |
pasteHTML | | | | | | | x | x | x | x |
| Pastes HTML text into the given text range, replacing any previous text and HTML elements in the range. |
| Syntax: TextRange .pasteHTML( HTMLText ) , where HTMLText is the HTML to paste into the range. See "Creating Text Ranges" in this chapter for an example. |
queryCommandEnabled | See Chapter 9 (Table 9.5). |
queryCommandIndeterm | See Chapter 9 (Table 9.5). |
queryCommandState | See Chapter 9 (Table 9.5). |
queryCommandSupported | See Chapter 9 (Table 9.5). |
queryCommandValue | See Chapter 9 (Table 9.5). |
scrollIntoView | See Chapter 6 |
select | | | | | | | x | x | x | x |
| Returns: Nothing |
| Selects the contents of the text range, making the selection visible in the browser. |
| Syntax: TextRange .select() . See "Selecting Text" in this chapter for an example. |
setEndPoint | | | | | | | x | x | x | x |
| Returns: Nothing |
| Sets the end point of one range based on the end point of another range. |
| Syntax: TextRange . setEndPoint( type , range ) , where the possible values of type are StartToEnd (moves the start of the TextRange object to the end of the range parameter), StartToStart (moves the start of the TextRange object to the start of the range parameter), EndToStart (moves the end of the TextRange object to the start of the range parameter), EndToEnd (moves the end of the TextRange object to the end of the range parameter). The range parameter holds the range to move with respect to. |