Selection对象,表示当前激活的高亮文本选区.
Selection对象获取
标本浏览器 :
window.getSelection();
IE :
document.selection;
兼容代码:
var selection = window.getSelection ? window.getSelection() : document.selection;
Selection对象取消选区
if(selection.removeAllRanges){
selection.removeAllRanges();
} else{
selection.empty();
}