1
저는 html + javascript + jQuery를 처음 사용했습니다. window.getSelection을 사용하여 선택한 텍스트를 가져 오려고하지만이 작업이 작동하지 않습니다. 누구든지이 문제에 대한 해결책을 제시 할 수 있습니까? 사전에window.getselection이 안드로이드에서 작동하지 않습니다.
감사합니다.
저는 html + javascript + jQuery를 처음 사용했습니다. window.getSelection을 사용하여 선택한 텍스트를 가져 오려고하지만이 작업이 작동하지 않습니다. 누구든지이 문제에 대한 해결책을 제시 할 수 있습니까? 사전에window.getselection이 안드로이드에서 작동하지 않습니다.
감사합니다.
시도
function getSelected() {
var text = "";
if (window.getSelection && window.getSelection().toString() && $(window.getSelection()).attr('type') != "Caret") {
text = window.getSelection();
return text;
} else if (document.getSelection && document.getSelection().toString() && $(document.getSelection()).attr('type') != "Caret") {
text = document.getSelection();
return text;
} else {
var selection = document.selection && document.selection.createRange();
if (!(typeof selection === "undefined") && selection.text && selection.text.toString()) {
text = selection.text;
return text;
}
}
return false;
}