CaretPosition

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The CaretPosition interface represents the caret position, an indicator for the text insertion point. You can get a CaretPosition using the Document.caretPositionFromPoint() method.

Instance properties

This interface doesn't inherit any properties.

CaretPosition.offsetNode Read only

Returns a Node containing the found node at the caret's position.

CaretPosition.offset Read only

Returns a long representing the offset of the selection in the caret position node. This will be the character offset in a text node or the selected child node's index in an element node.

Instance methods

CaretPosition.getClientRect

Returns the client rectangle for the caret range.

Specifications

Specification
CSSOM View Module
# caret-position

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
CaretPosition
getClientRect
offset
offsetNode

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

See also