Compartir a través de


IHTMLSelection interface

Represents the active selection, which is typically a highlighted block of text or other elements in the document. The active selection can be used to complete an action issued by a user or a script.

Members

The IHTMLSelection interface inherits from the IDispatch interface. IHTMLSelection also has these types of members:

  • Methods
  • Properties

Methods

The IHTMLSelection interface has these methods.

Method Description
addRange

Adds a Range to the current selection.

collapse

Replaces the current selection with an empty selection (or a caret) at the given offset.

collapseToEnd

Collapses or sets the insertion point or caret at the end of a selection object.

collapseToStart

Collapses, or sets the insertion point or caret at the beginning of a selection object.

deleteFromDocument

Deletes the selected nodes from a document.

getRangeAt

Returns a specified Range from a selection. The Range is specified by an index and cannot be greater than the number that is returned by IHTMLSelection::rangeCount.

removeAllRanges

Removes all ranges from a selection.

removeRange

Removes a range from a selection.

selectAllChildren

Replaces the current selection with all the contents of the given node.

 

Properties

The IHTMLSelection interface has these properties.

Property Description

anchorNode

Returns the element or node that contains the start of the selection.

anchorOffset

Retrieves the starting position of a selection that is relative to the IHTMLSelection::anchorNode.

focusNode

Retrieves the element or node that contains the end of a selection.

focusOffset

Retrieves the end position of a selection that is relative to the IHTMLSelection::focusNode.

isCollapsed

Retrieves whether a selection is collapsed or empty.

rangeCount

Returns the number of ranges in a selection

 

Requirements

Minimum supported client

Windows Vista with SP1, Windows 7

Minimum supported server

Windows Server 2008 R2

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll

See also

IDispatch