Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

focusOffset property

Retrieves the end position of a selection that is relative to the IHTMLSelection::focusNode.

HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 7.6.1Internet Explorer 9



HRESULT value = object.get_focusOffset(* p);

Property values

Type: long

The end position of the selection.

Standards information


IHTMLSelection::focusOffset typically refers to a character position within the text portion of the IHTMLSelection::focusNode.


The following example uses IHTMLSelection::focusOffset to show the offset value for the end of a selection when you release the mouse button.

<!DOCTYPE html>
<!-- this example displays the character offset from anchor node of your selection-->
    <title>Focus Offset Example</title>        
    <script type="text/javascript">         
      function getfocusOffset() {
        if (window.getSelection) {                      //only works if supported
           var selection = window.getSelection ();      //get the selection object     
           var focusOffsetProp = selection.focusOffset;   //get the offset
           alert ( "Offset: \n" + focusOffsetProp.toString());                                 
<div onmouseup="getfocusOffset()">    <!-- call the function when the mouse button is released -->
        Use the mouse to select some text within this field.
        When <strong>the left <em>button</em> is released</strong>, a dialog box appears with the anchor offset.
        The nested tags <strong>here and <em>there</em> can</strong> demonstrate different offsets as well.

See also




Community Additions

© 2015 Microsoft