我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译
您也可以阅读此文章的English (US)版。

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

文档标签和贡献者

此页面的贡献者: fscholz, chrisdavidmills, ConradIrwin, erikadoyle, Brettz9, teoli
最后编辑者: fscholz,