jamesktaylor
asked on
getSelection Start/End position
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER