Document: caretRangeFromPoint() method The caretRangeFromPoint() method of the Document interface returns a Range object for the document fragment under the specified coordinates. This method predates the concept of shadow DOM, and will return unpredictable and implementation-specific results in a document that contains ShadowRoot objects. Use caretPositionFromPoint() instead on supporting browsers because it is a standard method that can return the caret position from within ShadowRoot instances, provided the relevant shadow roots are passed in its options parameter. Syntax caretRangeFromPoint(x, y) Parameters x : A horizontal position within the current viewport. y : A vertical position within the current viewport. Return value One of the following: A Range. null, if x or y are negative, outside the viewport, or there is no text entry node. Examples Visit the Document.caretPositionFromPoint() page to view a live sample of this method. Specifications Not part of any specification. Browser compatibility See also Document.caretPositionFromPoint()