if(document.selection){ //IE var selectRange = document.selection.createRange(); if(selectRange.text.length > 0){ word = selectRange.text; }}else if(window.getSelection){ //FF 标准浏览器 word = window.getSelection().toString();}else if(document.getSelection){ //一个比较老的方法 word = document.getSelection();}
文章来源: