Javascript: How to detect if a word is highlighted
The easiest way to do this is to detect mouseup and keyup events on the document and check whether any text is selected. The following will work in all major browsers. Example: http://www.jsfiddle.net/timdown/SW54T/ function getSelectedText() { var text = “”; if (typeof window.getSelection != “undefined”) { text = window.getSelection().toString(); } else if (typeof document.selection != … Read more