We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

Document.onselectionchange

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The Document.onselectionchange property represents the event handler that is called when a selectionchange event reaches this object.

Syntax

obj.onselectionchange = function;
  • function is the name of a user-defined function, without the () suffix or any parameters, or an anonymous function declaration.

Example

document.onselectionchange = function() { console.log("Selection changed!"); }; 

Specifications

Specification Status Comment
Selection API
The definition of 'Document.onselectionchange' in that specification.
Working Draft Initial definition.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support49 Yes451 2 ? ? ?
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support4949 Yes451 2 ? ? ?

1. Flag not necessary on Nightly

2. From version 45: this feature is behind the dom.select_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

See also

Document Tags and Contributors

Contributors to this page: fscholz, chrisdavidmills, ConradIrwin, erikadoyle, Brettz9, teoli
Last updated by: fscholz,