TextRange object (Object/JScript)

An object that represents part of the text stream of an HTML document.

Availability:

JScript - 3.0
Internet Explorer - 4.0
Inherits from:Element object
JavaScript syntax:IEmyTextRange = myElement.createTextRange()
Object properties:boundingHeight, boundingLeft, boundingTop, boundingWidth, htmlText, text
Object methods:collapse(), compareEndPoints(), duplicate(), execCommand(), expand(), findText(), getBookmark(), getBoundingClientRect(), getClientRects(), inRange(), isEqual(), move(), moveEnd(), moveStart(), moveToBookmark(), moveToElementText(), moveToPoint(), parentElement(), pasteHTML(), queryCommandEnabled(), queryCommandIndeterm(), queryCommandState(), queryCommandSupported(), queryCommandText(), queryCommandValue(), select(), setEndPoint()

The main purpose of a TextRange object is to encapsulate that part of the document text that depends on the user having used the mouse to select a portion of text. A TextRange object can also encapsulate an insertion point in the text of a document.

An insertion point is encapsulated by creating a TextRange object that is of zero length.

A new TextRange object is instantiated with the createTextRange() method which can be applied to the following object types which can contain selectable text:

The TextCell and TEXTAREA objects are members of the Form Element category, sometimes called Input Elements.

When you have created a TextRange object, you can then manipulate its properties to select just that portion of text in the document that you want.

Once you have marked the text you want within the start and end points, you can replace the content of the TextRange with the pasteHTML() method to operate on the text in the document. However, there may be limitations on when and how you can do this depending on the extent of the TextRange object's boundaries.

Warnings:

See also:BODY.createTextRange(), Button object, BUTTON object, Element.isTextEdit, Element.parentTextEdit, Input.createTextRange(), Selection object, selection.createRange(), TEXTAREA object, TextCell object

PropertyJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
boundingHeight n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/aReadOnly.
boundingLeft n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/aReadOnly.
boundingTop n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/aReadOnly.
boundingWidth n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/aReadOnly.
htmlText n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/aReadOnly.
text n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-

MethodJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
collapse() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
compareEndPoints() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
duplicate() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
execCommand() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
expand() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
findText() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
getBookmark() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
getBoundingClientRect() n/a5.0 5.0 n/a5.0 5.0 n/a n/a n/a n/a n/a n/a-
getClientRects() n/a5.0 5.0 n/a5.0 5.0 n/a n/a n/a n/a n/a n/a-
inRange() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
isEqual() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
move() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
moveEnd() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/aWarning
moveStart() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/aWarning
moveToBookmark() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
moveToElementText() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
moveToPoint() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
parentElement() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
pasteHTML() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
queryCommandEnabled() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
queryCommandIndeterm() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
queryCommandState() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
queryCommandSupported() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
queryCommandText() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
queryCommandValue() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
select() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
setEndPoint() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-

Inheritance chain:

Element object, Node object