Javascript Reference
Categories: TextRange

javascript TextRange Description

@Aug. 15, 2009, 11:54 a.m.
TextRange Firefox/Netscape/NN n/a IE 4(Win) Chrome/Safari/DOM n/a  



The TextRange object--similar in concept to the Netscape 6 and W3C DOM Range objectrepresents the text of zero or more characters in a document. When a text range consists of zero characters, it represents an insertion point between two characters (or before the first or after the last character).


A TextRange object is created via the createTextRange( ) method associated with the body, button, text, or textarea objects. You can also turn a user selection into a range via the selection object's createRange( ) (note the slight difference in the method name). Once you have created a text range, use its methods to adjust its start and end points to encompass a desired segment of the text (such as text that matches a search string). Once the range has been narrowed to the target text, assign values to its htmlText and text properties to change, remove, or insert text. A library of direct commands that perform specific textual modifications can also be invoked to act on the text range.


Shared properties and methods from the list at the start of this category are: offsetLeft, offsetTop, getBoundingClientRect( ), getClientRects( ), and scrollIntoView( ). Note that the TextRange object and all associated facilities are available only in the Win32 version of Internet Explorer.

Object Model Reference
objectRef.createTextRange( )
selectionObjectRef.createRange( )
Object-Specific Properties
boundingHeight boundingLeft boundingTop boundingWidth
htmlText text    
Object-Specific Methods
collapse( ) compareEndPoints( ) duplicate( )
execCommand( ) expand( ) findText( )
getBookmark( ) inRange( ) isEqual( )
move( ) moveEnd( ) moveStart( )
moveToBookmark( ) moveToElementText( ) moveToPoint( )
parentElement( ) pasteHTML( ) queryCommandEnabled( )
queryCommandIndeterm( ) queryCommandState( ) queryCommandSupported( )
queryCommandText( ) queryCommandValue( ) select( )
setEndPoint( )    

Powered by Linode.