The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
Creates a TextRange object for the element.
Syntax
object.createTextRange()Standards information
There are no standards that apply here.
Parameters
This method has no parameters.
Return value
Type: TextRangeReturns a TextRange object if successful, or null otherwise.
Remarks
Use a text range to examine and modify the text within an object.
Examples
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>
See also
- body
- button
- input type=button
- input type=hidden
- input type=password
- input type=reset
- input type=submit
- input type=text
- textArea
Send comments about this topic to Microsoft
Build date: 11/8/2012