cssjs-func-lib/selText.js
2022-07-14 09:40:04 +02:00

15 lines
386 B
JavaScript

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(selection.toString() !== '') {
callback(selection.toString(),e.pageX, e.pageY);
}
});
};