createTextRangecreateTextRange*
*



Contents  *



Index  *Topic Contents
*Previous Topic: createStyleSheet
*Next Topic: createTHead

createTextRange

Description

Creates a text range object for the given object. You use a text range to examine and modify the text within an object.

Syntax

TextRange = object.createTextRange( )

Return Value

Returns a text range object if successful, or NULL otherwise.

Examples

The following JScript example creates a text range for the document, then uses the range to display all text and HTML tags in the document.

var rng = document.body.createTextRange( );
if (rng!=null) {
    alert(rng.htmlText);
}

The following JScript example creates a text range for the first BUTTON element in the document, then uses the text range to change the text in the button.

var coll = document.all.tags("BUTTON");
if (coll!=null && coll.length>0) {
    var rng = coll[0].createTextRange();
    rng.text = "Clicked";
}

Applies To

BODY, BUTTON, INPUT (text type only), TEXTAREA

See Also

TextRange


Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.