Javascript Reference
Categories: Range

javascript Range Description

@Aug. 15, 2009, 12:18 p.m.
Range Firefox/Netscape/NN 6 IE n/a Chrome/Safari/DOM 2  

 

  

The W3C DOM Range objectsimilar in concept to the IE TextRange objectrepresents a sequence of zero or more rendered text 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 of the document). The Range object automatically keeps track of the node and character offset references for the start and end points of the range, so its methods can copy existing content, delete the range's contents, or insert new contents (in node form) into the existing range while maintaining the integrity of the document tree at every step. Nodeness is important to the Range object, but most of those concerns are handled for you.

 

A Range object is created via the document.createTextRange( ) method or by turning a user selection into a range via window.getSelection( ).getRangeAt(0). Once a text range is created, use its methods to adjust its start and end point to encompass a desired segment of the text. The choose from a set of additional methods to act on the range. See how its syntax varies from that of the IE TextRange object.

 
Object Model Reference
 
document.createRange( )
 
Object-Specific Properties
 
collapsed commonAncestorContainer endContainer
endOffset startContainer startOffset
 
Object-Specific Methods
 
cloneContents( ) cloneRange( ) collapse( )
compareBoundaryPoints( ) compareNode( ) comparePoint( )
createContextualFragment( ) deleteContents( ) detach( )
extractContents( ) insertNode( ) intersectsNode( )
isPointInRange( ) selectNode( ) selectNodeContents( )
setEnd( ) setEndAfter( ) setEndBefore( )
setStart( ) setStartAfter( ) setStartBefore( )
surroundContents( ) toString( )  
 
Object-Specific Event Handler Properties

None.


Powered by Linode.