1 var txt; 2 if(window.getSelection) 3 { 4 txt = window.getSelection().toString(); 5 } 6 else 7 { 8 txt = document.selection.createRange().text; 9 }