阅读(2726) (0)

window属性:onselectionchange

2018-05-28 11:15:19 更新

onselectionchange属性

使用此功能之前,请仔细检查浏览器兼容性表。

该GlobalEventHandlers.onselectionchange属性表示selectstart事件触发时调用的事件处理程序,即当网页上选定的文本发生更改时。

onselectionchange属性语法

obj .onselectionchange = function ;

onselectionchange属性示例

var selection;

document.onselectionchange = function() {
  console.log('New selection made');
  selection = document.getSelection();
};

规范

规范状态注释
Selection API
该规范中的'GlobalEventHandlers.onselectionchange'的定义。
Working Draft
初始定义。

浏览器兼容性

我们正在将兼容性数据转换为机器可读的JSON格式。 

  • 电脑端
特征Firefox(Gecko)Chrome
Internet Explorer
Opera
Safari
基本支持支持:43[1] 、52[2]支持支持支持:1.3
  • 移动端
特征Firefox Mobile (Gecko)AndroidIE MobileOpera MobileSafari Mobile
onselectionchange支持:43.0[1]、52.0[2]????

注释:

[1]这是在dom.select_events.enabled首选项后面实现的,处除了Nightly,其余默认为false。

[2]现已在Firefox 52发行版中完全启用。