When using methods of selecting text and restoring selected text in a page, I have found that running execCommand('insertHTML...
inbetween causes the stored selection to break.
This is a sample of how the text is selected and restored.
// Get Selection
var sel = window.getSelection().getRangeAt(0);
// Clear Selections
window.getSelection().removeAllRanges();
// Restore Selection
window.getSelection().addRange(sel)
This works fine, however once you run execCommand('insertHTML..
the selections endOffset
sets itself to the same value as the selections startOffset
Is there a reason for this? More importantly is there a way round this?
A full example of the bug, complete with some basic console logging can be seen here. http://jsfiddle.net/blowsie/Y8pJ7/
The objective of this fiddle is to select text , transform it to uppercase and then reselect the text.