The onselect property of the GlobalEventHandlers mixin is an EventHandler that processes select events.

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

Syntax

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

Example

<html>
<head>

<title>onselect test</title>

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

<script type="text/javascript">
window.onselect = selectText;

function selectText() {
  alert("select event detected!");
}
</script>
</head>

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

Specification

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

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support YesEdge Full support YesFirefox Full support YesIE ? Opera ? Safari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

Document Tags and Contributors

Last updated by: mfluehr,