JavaScript Selection对象

Selection对象,表示当前激活的高亮文本选区.

Selection对象获取

标本浏览器 :

   window.getSelection();

IE :

  document.selection;

兼容代码:

var selection = window.getSelection ? window.getSelection() : document.selection;

Selection对象取消选区

 if(selection.removeAllRanges){

  selection.removeAllRanges();

} else{

  selection.empty();

}

 

posted @ 2014-01-12 13:20  _彭建  阅读(240)  评论(0编辑  收藏  举报