One of the things I\'d like to do in my browser-based application is allow the user to select some text (not in a
These days this method should be enough:
function getSelectedText() {
return window.getSelection ? window.getSelection().toString() : '';
}
It will return ''
in rare occasions of really old browsers and may be in the case of Opera Mini (to be tested, though, this may be outdated) + see note for UC Browser for Android.