📜 ⬆️ ⬇️

W3C Range for Internet Explorer

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:
Below is an example of using the Range object for IE:
')
var range = new Range (document.selection.createRange()); // range

or as usual

var range = document.createRange(); // , range

Download the object here: W3C Range for IE

I would be glad if the script is useful to you.

Source: https://habr.com/ru/post/53674/


All Articles