--- title: GlobalEventHandlers.onselectionchange slug: Web/API/GlobalEventHandlers/onselectionchange translation_of: Web/API/GlobalEventHandlers/onselectionchange ---
GlobalEventHandlers.onselectionchange
属性表示当一个 {{event("selectstart")}} 事件被触发,比如在页面上选中文字变化时,会执行绑定的事件处理器
obj.onselectionchange = function;
var selection; document.onselectionchange = function() { console.log('New selection made'); selection = document.getSelection(); };
完整例子请参阅Key quote generator demo.
Specification | Status | Comment |
---|---|---|
{{SpecName('Selection API','#dom-globaleventhandlers-onselectionchange','GlobalEventHandlers.onselectionchange')}} | {{Spec2('Selection API')}} | Initial definition. |