我想在文本区域中实时复制/粘贴突出显示的文本,然后发送。我怎样才能做到这一点 ?我有一些东西可以在弹出窗口中获取选定的文本:
if(!window.Kolich){
Kolich = {};
}
Kolich.Selector = {};
// getSelected() was borrowed from CodeToad at
// http://www.codetoad.com/javascript_get_selected_text.asp
Kolich.Selector.getSelected = function(){
var t = '';
if(window.getSelection){
t = window.getSelection();
}else if(document.getSelection){
t = document.getSelection();
}else if(document.selection){
t = document.selection.createRange().text;
}
return t;
}
Kolich.Selector.mouseup = function(){
var st = Kolich.Selector.getSelected();
if(st!=''){
alert("You selected:\n"+st);
}
}
$(document).ready(function(){
$(document).bind("mouseup", Kolich.Selector.mouseup);
});
谢谢 !