js 获取鼠标选中值

if (window.getSelection) {//一般浏览器
userSelection = window.getSelection();
} else if (document.selection) {
//IE浏览器、Opera
userSelection = document.selection.createRange();
}
var strInput="";
try{
strInput+=" "+userSelection.toString();
}catch(e){//I兼容IE

strInput+=" "+userSelection.text;
}
谷歌中对象

js 获取鼠标选中值

IE中对象

js 获取鼠标选中值

上一篇:1019psp


下一篇:python学习笔记八--动态类型