复制代码代码如下:
function getSelectedText() { //este código de função foi emprestado de: http://www.codetoad.com/javascript_get_selected_text.asp
vartxt = "";
if (window.getSelection) {
txt = janela.getSelection();
} else if (window.document.getSelection) {
txt = window.document.getSelection();
} else if (window.document.selection) {
txt = window.document.selection.createRange().text;
}
retornar txt;
}