Click to return to the DHTML, HTML     
createTextNode Method     createTFoot Method     DHTML Methods    
Web Workshop  |  DHTML, HTML & CSS

createTextRange Method


Creates a TextRange object for the given object.

Syntax

oTextRange = object.createTextRange()

Return Value

Returns a TextRange object if successful, or null otherwise.

Remarks

Use a text range to examine and modify the text within an object.

Example

This example uses the createTextRange method to create a text range for the document, and then uses the text range to display all the text and HTML tags in the document.

<SCRIPT LANGUAGE="JScript">
var rng = document.body.createTextRange( );
if (rng!=null) {
    alert(rng.htmlText);
}
</SCRIPT>

This example uses the createTextRange method to create a text range for the first BUTTON element in the document, and then uses the text range to change the text in the button.

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

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
BODY, BUTTON, INPUT TYPE=button, INPUT TYPE=hidden, INPUT TYPE=password, INPUT TYPE=reset, INPUT TYPE=submit, INPUT TYPE=text, TEXTAREA

See Also

TextRange



Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.