Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Collapse the table of content
Expand the table of content

setSelectionRange method

Sets the start and end positions of a selection in a text field.

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



HRESULT retVal = object.setSelectionRange(start, end);


start [in]

Type: long

The offset into the text field for the start of the selection.

end [in]

Type: long

The offset into the text field for the end of the selection.

Return value


If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Standards information


If you set a parameter to more than the length of the text field, the parameter points to the end of the text field. If the end parameter is less than or equal to the start paramenter, the start and end positions of the selection are set to the end value. The selection is then an insertion point or caret.



Community Additions

© 2015 Microsoft