In javascript, there is a wonderful Range object that is part of the DOM standard defined by the world wide web consortium. In IE7, they promised to include support for Range, but it remained so in words. The TextRange object available in IE (and only in IE) does not hold water and is not suitable for anything serious (you can write an entire article about the marasmus of this object).
I had the task to write a WYSIWYG editor that generates absolutely valid and absolutely not redundant html. Without Range was not enough. From the finished one in the internet, I found only a non-working script of a certain Jorgen Horstink, so Range for IE had to be written from scratch. The script turned out quite weighty (41 kb), but if you remove spaces, tabs, shorten the names of variables, I think up to 15 kb can be compressed. Due to the quirks of Explorera, the script completely corresponded 3 times. The object imitating the work of Range for IE was tested on an already finished WYSIWYG editor, whose work is completely based on the Range.
Among the shortcomings of the work I can note the following:
The startOffset or endOffset value of any range may become incorrect if some kind of DOM (insertion or deletion) manipulation was performed. But it just costs the correct sequence of actions of the script, especially since in other browsers I have such problems (especially in Opera).
Below is an example of using the Range object for IE: ')
var range = new Range (document.selection.createRange()); // range