textselection

This commit is contained in:
Sebastian Titz
2022-07-14 09:40:04 +02:00
parent 240a1f999a
commit 84535957c8
3 changed files with 37 additions and 10 deletions

View File

@@ -1,13 +1,15 @@
$(function(){
$(document.body).bind('mouseup', function(e){
var selection;
var selText = function(callback){
document.body.addEventListener('mouseup', function(e){
var selection;
if (window.getSelection) {
selection = window.getSelection();
} else if (document.selection) {
selection = document.selection.createRange();
}
if (window.getSelection) {
selection = window.getSelection();
} else if (document.selection) {
selection = document.selection.createRange();
}
selection.toString() !== '' && alert('"' + selection.toString() + '" was selected at ' + e.pageX + '/' + e.pageY);
if(selection.toString() !== '') {
callback(selection.toString(),e.pageX, e.pageY);
}
});
});
};