GlobalEventHandlers.onselectionchange
GlobalEventHandlers.onselectionchange
属性表示当一个 selectstart
事件被触发,比如在页面上选中文字变化时,会执行绑定的事件处理器
语法
obj.onselectionchange = function;
示例
js
var selection;
document.onselectionchange = function () {
console.log("New selection made");
selection = document.getSelection();
};
完整例子请参阅Key quote generator demo.
规范
Specification |
---|
Selection API # selectionchange-event |
Selection API # dom-globaleventhandlers-onselectionchange |
浏览器兼容性
BCD tables only load in the browser