Join MDN and developers like you at Mozilla's View Source conference, November 2-4 in Portland, Oregon. Learn more at


An event handler for the select event on the window.


window.onselect = funcRef;
  • funcRef is a function.



<title>onselect test</title>

<style type="text/css">
.text1 { border: 2px solid red; }

<script type="text/javascript">

window.onselect = selectText;

function selectText()
 alert("select event detected!");

<textarea class="text1" cols="30" rows="3">
Highlight some of this text
with the mouse pointer
to fire the onselect event.


The select event only fires when text inside a text input or textarea is selected. The event is fired after the text has been selected.


Specification Status Comment
WHATWG HTML Living Standard
The definition of 'onselect' in that specification.
Living Standard  

Document Tags and Contributors

Contributors to this page: cvrebert, teoli, fscholz, kscarfone, Sheppy, ziyunfei, Jabez, Nickolay, Mw22, Rappo
Last updated by: cvrebert,
Hide Sidebar