15 lines
386 B
JavaScript
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);
|
|
}
|
|
});
|
|
}; |