2 ms·
Honestly, I haven't looked into it. The bounding box thing sounds messy. But on chrome, firefox, and probably safari, it appears that you can call document.get
by dunham 13y ago
Honestly, I haven't looked into it. The bounding box thing sounds messy.
But on chrome, firefox, and probably safari, it appears that you can call document.getSelection() in a click handler, and the returned object will be an appropriate Caret selection with offset and node.
I recall that the selection object in older versions of IE do not offer the character offset, so you have to copy the selection and move it one character at a time until you get to the beginning of the text node. IE9 and above appear to have modern selection objects (according the MS docs). I don't know if they're updated onclick.