Javascript Reference
Categories: TextRange

javascript TextRange expand( )

@March 15, 2008, 1:22 a.m.
expand( )Firefox/Netscape/NN n/a IE 4(Win) Chrome/Safari/DOM n/a  

expand("unit")

  

Expands the current text range (including a collapsed range) to encompass the textual unit passed as a parameter. For example, if someone selects some characters from a document, you can create the range and expand it to encompass the entire sentence in which the selection takes place:

var rng = document.selection.createRange( );
rng.expand("sentence");
 

If the starting range extends across multiple units, the expand( ) method expands the range outward to the next nearest unit.

 
Parameters
 
  • A case-insensitive string value of the desired unit: character | word | sentence | textedit. The textedit value expands the range to the entire original range.
 
Returned Value

Boolean value: true if method is successful; false if unsuccessful.


Powered by Linode.