我是靠谱客的博主 紧张巨人,这篇文章主要介绍Javascript selection的兼容性写法介绍,现在分享给大家,希望可以做个参考。

复制代码 代码如下:
复制代码

function getSelectedText() { //this function code is borrowed from: http://www.codetoad.com/javascript_get_selected_text.asp

var txt = "";
if (window.getSelection) {
txt = window.getSelection();
} else if (window.document.getSelection) {
txt = window.document.getSelection();
} else if (window.document.selection) {
txt = window.document.selection.createRange().text;
}
return txt;
}

最后

以上就是紧张巨人最近收集整理的关于Javascript selection的兼容性写法介绍的全部内容,更多相关Javascript内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(177)

评论列表共有 0 条评论

立即
投稿
返回
顶部