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.


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


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


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: Konrud, fscholz, chrisdavidmills, ConradIrwin, erikadoyle, Brettz9, teoli
Last updated by: Konrud,