我试图在选择时在 android 中获取选定的文本。它在触摸设备中不起作用。但它在普通浏览器中运行良好。
if(!window.Kolich) {
Kolich = {};
}
Kolich.Selector = {};
// getSelected() was borrowed from CodeToad at
// http://www.codetoad.com/javascript_get_selected_text.asp
Kolich.Selector.getSelected = function() {
var t = '';
if(window.getSelection) {
t = window.getSelection();
}
else if(document.getSelection) {
t = document.getSelection();
}
else if(document.selection){
t =document.selection.createRange().text;
}
return t;
}
Kolich.Selector.mouseup = function(e){
var st = Kolich.Selector.getSelected();
alert(st);
}
但是Android触摸选择不适用于此代码..请帮助