I'm trying to run the following bookmarklet from This article on Firefox and Chrome on Android, but it doesn't work. It works on Windows Firefox, though.
alert(getSelectionText()));
function getSelectionText() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
}
return text;
}
On Android, it will just show an empty alert message. I assume I overlooked some conceptual key difference? Any suggestion on how to fix it?