1 out of 9 rated this helpful - Rate this topic

expand method

Expands the range so that partial units are completely contained.

Syntax

var retval = TextRange.expand(Unit);

Standards information

There are no standards that apply here.

Parameters

Unit [in]

Type: String

String that specifies the units to move in the range, using one one of the following values:

character

Expands a character.

word

Expands a word. A word is a collection of characters terminated by a space or another white-space character, such as a tab.

sentence

Expands a sentence. A sentence is a collection of words terminated by an ending punctuation character, such as a period.

textedit

Expands to enclose the entire range.

Return value

Type: Boolean

Boolean that returns one of the following values:

Return valueDescription
true

The range was successfully expanded.

false

The range was not expanded.

 

Remarks

This feature might not be available on non-Microsoft Win32 platforms.

Examples

This example creates a range from the current selection and uses the expand method to ensure that any word partially enclosed in the range becomes entirely enclosed in the range.


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

See also

TextRange
collapse

 

 

Send comments about this topic to Microsoft

Build date: 11/8/2012

Community Additions

ADD
© 2013 Microsoft. All rights reserved.