Click to return to the DHTML, HTML     
TextNode Object     TextRectangle Object     DHTML Objects    
Web Workshop  |  DHTML, HTML & CSS

TextRange Object


Represents text in an HTML element.

Remarks

Use this object to retrieve and modify text in an element, to locate specific strings in the text, and to carry out commands that affect the appearance of the text.

To retrieve a text range object, apply the createTextRange method to a BODY, BUTTON, or TEXTAREA element or an INPUT element that has text type.

Modify the extent of the text range by moving its start and end positions with methods such as move, moveToElementText, and findText. Within the text range, you can retrieve and modify plain text or HTML text. These forms of text are identical except that HTML text includes HTML tags, and plain text does not.

This feature might not be available on non-Win32® platforms. See article Q172976 Non-MSDN link in the Microsoft® Knowledge Base for the latest information on Internet Explorer cross-platform compatibility.

This object is available in script as of Microsoft® Internet Explorer 4.0.

Members

Example

This example changes the text of a BUTTON element to "Clicked" through the TextRange object.

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

See Also

createTextRange



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.