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

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic support
Experimental
Chrome Full support 49Edge Full support YesFirefox Full support 45
Notes Disabled
Full support 45
Notes Disabled
Notes Flag not necessary on Nightly
Disabled 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.
IE ? Opera ? Safari ? WebView Android Full support 49Chrome Android Full support 49Edge Mobile Full support YesFirefox Android Full support 45
Notes Disabled
Full support 45
Notes Disabled
Notes Flag not necessary on Nightly
Disabled 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.
Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.

See also

Document Tags and Contributors

Last updated by: mfuji09,