{{ApiRef('DOM')}}{{SeeCompatTable}}
The Document.onselectionchange
property represents the event handler that is called when a {{event("selectionchange")}} event reaches this object.
Syntax
obj.selectionchange = 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 |
---|---|---|
{{SpecName('Selection API','','Document.onselectionchange')}} | {{Spec2('Selection API')}} | Initial definition. |
Browser compatibility
{{CompatibilityTable}}
Feature | Firefox (Gecko) | Chrome | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatGeckoDesktop(45)}}[1] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Firefox Mobile (Gecko) | Android | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
onselectionchange |
{{CompatGeckoMobile(45)}}[1] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
[1] This is implemented behind the dom.select_events.enabled
preference, that default to false
, except on Nightly.
See also
- {{event("selectionchange")}}
- {{domxref("GlobalEventHandlers.onselectstart")}} and {{event('selectstart')}}.