Share via


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
  • Properties

Methods

The IHTMLSelectionObject interface has these methods.

Method Description
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.

Property Description

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

Minimum supported server

Windows 2000 Server

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll

See also

IDispatch