如何用JavaScript实现选中文字的获取功能?
- 内容介绍
- 文章标签
- 相关推荐
本文共计85个文字,预计阅读时间需要1分钟。
javascript获取选中的文字/*var _getSelectedText=function() { if (window.getSelection) { return window.getSelection().toString(); } else if (document.getSelection) { return document.getSelection(); } else if (document.s%E2%80%9D) { // 旧版浏览器 return document.s%E2%80%9D selections[0].text; }}*/
/*获取选中的文字*/ var _getSelectedText = function() { if (window.getSelection) { return window.getSelection().toString(); } else if (document.getSelection) { return document.getSelection(); } else if (document.selection) { return document.selection.createRange().text; }else{ return ""; } }
本文共计85个文字,预计阅读时间需要1分钟。
javascript获取选中的文字/*var _getSelectedText=function() { if (window.getSelection) { return window.getSelection().toString(); } else if (document.getSelection) { return document.getSelection(); } else if (document.s%E2%80%9D) { // 旧版浏览器 return document.s%E2%80%9D selections[0].text; }}*/
/*获取选中的文字*/ var _getSelectedText = function() { if (window.getSelection) { return window.getSelection().toString(); } else if (document.getSelection) { return document.getSelection(); } else if (document.selection) { return document.selection.createRange().text; }else{ return ""; } }

