getSelection Start/End position
Posted on 2006-07-06
Hi there, been searching the web with no avail. Basically, what I'm trying to do is get the start/end position of highlighted text. So, say for example we have:
Hello my name is Jimmy
The word 'Hello' is highlighted, button clicked. Start position would be 0, end 4 or so.
Positions are pretty much all I need to know, the selection would initially be made with getSelection() or createRange() for compatibility.
I've seen some methods such as anchorOffset, focusOffset, anchorNode, anchorOffset, but I just can't seem to get them working. JS newbie, the DOM documentation and web documentation isn't really helping.
Any thoughts would be highly appreciated.