Skip to content
SiteEmail

Selection

Module: JavaScript DOM API

The navigator of the view.

#include <Selection.idl>

Name
voidremoveAllRanges()
Removes all ranges from the selection.
voidempty()
Clear the selection. This is an alias for removeAllRanges().
voidsetBaseAndExtent(Node anchorNode, unsigned long anchorOffset, Node focusNode, unsigned long focusOffset)
Sets the selection to be a range including all or parts of two specified DOM nodes, and any content located between them.
DOMStringtoString()
Returns a string currently being represented by the selection object, i.e. the currently selected text.
Name
readonly attribute NodeanchorNode
Returns the Node in which the selection begins. Can return null if selection never existed in the document.
readonly attribute unsigned longanchorOffset
Returns a number representing the offset of the selection’s anchor within the anchorNode.
readonly attribute NodefocusNode
Returns the Node in which the selection ends. Can return null if selection never existed in the document.
readonly attribute unsigned longfocusOffset
Returns a number representing the offset of the selection’s anchor within the focusNode.
void removeAllRanges()

Removes all ranges from the selection.

void empty()

Clear the selection. This is an alias for removeAllRanges().

void setBaseAndExtent(
Node anchorNode,
unsigned long anchorOffset,
Node focusNode,
unsigned long focusOffset
)

Sets the selection to be a range including all or parts of two specified DOM nodes, and any content located between them.

DOMString toString()

Returns a string currently being represented by the selection object, i.e. the currently selected text.

readonly attribute Node anchorNode;

Returns the Node in which the selection begins. Can return null if selection never existed in the document.

readonly attribute unsigned long anchorOffset;

Returns a number representing the offset of the selection’s anchor within the anchorNode.

readonly attribute Node focusNode;

Returns the Node in which the selection ends. Can return null if selection never existed in the document.

readonly attribute unsigned long focusOffset;

Returns a number representing the offset of the selection’s anchor within the focusNode.