I have the following code:
<div id="textBox" contenteditable="true"></div>
I use the following code to get the selected text within the div.
if (document.getSelection) {
var sel = document.getSelection();
selRange = sel;
return sel;
}
As you can see, I save the selected range in a global variable called selRange.
What I want is to be able to reSELECT the previously selected text once it has been deselected after the user has clicked away.
What I've noticed is that range saves the startOffSet which is always 0 and the focusOffset which ends up being the length of the selected range (this is true when the code in the div looks like this: test <strong>test</strong> test). But nothing else about where in the full text the user has selected.
Is that possible?
Thanks