You can use document.selection.createRange().text in IE and window.getSelection().toString() in firefox and webkit and attach to the ondblclick handler as follows:
document.ondblclick = function () { var sel = (document.selection && document.selection.createRange().text) || (window.getSelection && window.getSelection().toString()); alert(sel); };
References
- MSDN , for
document.selection - MDN , for
window.getSelection()
David tang
source share