textselection
This commit is contained in:
22
selText.js
22
selText.js
@@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user