当前位置:小鱼儿玄机二站 > 前端技术 > selection的包容性写法介绍,selection的包容性写法

selection的包容性写法介绍,selection的包容性写法

文章作者:前端技术 上传时间:2019-09-03

复制代码 代码如下:

Javascript selection的包容性写法

 本文为大家批注下Javascript selection的包容性写法,感兴趣的爱侣能够参照下

 代码如下:

function getSelectedText() { //this function code is borrowed from:  

 

var txt = ""; 

if (window.getSelection) { 

txt = window.getSelection(); 

} else if (window.document.getSelection) { 

txt = window.document.getSelection(); 

} else if (window.document.selection) { 

txt = window.document.selection.createRange().text; 

return txt; 

 

 

selection的包容性写法 本文为大家批注下Javascript selection的兼容性写法,感兴趣的爱人能够参照他事他说加以考察下 代码如下: function getSelectedText() {...

function getSelectedText() { //this function code is borrowed from:

var txt = "";
if (window.getSelection) {
txt = window.getSelection();
} else if (window.document.getSelection) {
txt = window.document.getSelection();
} else if (window.document.selection) {
txt = window.document.selection.createRange().text;
}
return txt;
}

代码如下: function getSelectedText() { //this function code is borrowed from: var txt = ""; if (window.get...

本文由小鱼儿玄机二站发布于前端技术,转载请注明出处:selection的包容性写法介绍,selection的包容性写法

关键词: