asp.net.ph

Skip Navigation Links

createTextRange Method

DHTML Methods


Creates a TextRange object for the given object. Use a text range to examine and modify the text within an object.

Syntax

oTextRange = object.createTextRange ( ) 
Return Value

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

Example

The following JScript™ ( compatible with ECMA-262 language specification ) example creates a text range for the document and 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 and 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, HTMLAREA, INPUT type=button, INPUT type=hidden, INPUT type=password, INPUT type=reset, INPUT type=submit, INPUT type=text, TEXTAREA

See Also

TextRange



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note