Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
IHTMLSelectionObject
Collapse the table of content
Expand the table of content

IHTMLSelectionObject interface

This interface provides the access methods for the selection object that represents the active selection, a highlighted block of text, or other elements in the document upon which a user or a script can carry out some action.

Members

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

Methods

The IHTMLSelectionObject interface has these methods.

MethodDescription
clear

Clears the contents of the selection.

createRange

Creates a TextRange object from the current text selection, or a controlRange collection from a control selection.

empty

Cancels the current selection, sets the selection type to none, and sets the item property to null.

 

Properties

The IHTMLSelectionObject interface has these properties.

PropertyDescription

type

Retrieves the type of selection.

 

Remarks

You can use the selection object as input from the user that identifies on what portion of the document to act, or as output to the user showing the results of an action.

Users and scripts can both create selections. Users create selections by dragging the mouse pointer over a portion of the document. Scripts create selections by calling the IHTMLTxtRange::select method on a text range or similar object. You can retrieve the active selection by applying the selection keyword to the document object. You can create a text range object from the selection by using the IHTMLSelectionObject::createRange method.

A document can have only one selection at a time. The selection has a type that determines whether it is empty or contains a contiguous block of consecutive text or elements. Although an empty selection contains nothing, it is useful for marking a position in the document.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll

See also

IDispatch

 

 

Community Additions

ADD
Show:
© 2015 Microsoft