Suppose I have this HTML element:
<div id="parent"> Hello everyone! <a>This is my home page</a> <p>Bye!</p> </div>
And the user selects "home" with his mouse.
I want to be able to determine how many characters into
#parent his selection starts (and how many characters from the end of
#parent his selection ends). This should work even if he selects an HTML tag. (And I need it to work in all browsers)
range.startOffset looks promising, but it is an offset relative only to the range's immediate container, and is a character offset only if the container is a text node.