Have you viewed the quirksmode article in Range?
Based on this article, you can create a method like this:
function getRangeText() { var userSelection; if (window.getSelection) { userSelection = window.getSelection(); } else if (document.selection) { userSelection = document.selection.createRange(); } var selectedText = userSelection; if (userSelection.text) { selectedText = userSelection.text; } return selectedText; }
I tested this on FF5, Opera 11, Safari on Mac, as well as IE6 and IE7. This is worth checking out in other IE browsers, but I think it works in them too.
source share