I have a page with formated text and a toolbar (images with click events) beside it. One of the tool-commands is meant to be "mark yellow". (The text has to be read only and is formated.)
I tried to use document.getSelection() and window.getSelection(), but they seem to be designed for input fields only.
The other problem is, that as I click the tool bar my selection gets lost.
How do I get the selected text without loosing the selection?
Solution:
The clue was to use onmousedown=""
or jQuery: .mousedown() function to avoid loosing the selection.