0

I need the equivalent to the getRangeAt() method in Internet Explorer before version 9

if (window.getSelection) {
    sel = window.getSelection();
    if (sel.rangeCount) {
        range = sel.getRangeAt(0);
    }
} else if (document.selection && document.selection.createRange) {
    // What shall I write here to do the same thing in IE before version 9
}


var table = document.createElement("table");
table.border = 1;
table.className = "tabley";
range.insertNode(table);
Develop Smith
  • 146
  • 1
  • 3
  • 13

1 Answers1

0

document.selection.createRange(); is the code which creates a range object in IE<9 and is equivalent to getRangeAt method used in IE>= 9

Dushyanth
  • 143
  • 3
  • 9
  • That usually creates a `TextRange`, which serves a similar purpose to a DOM Range but has a very different API, so they're not really equivalent. – Tim Down Jul 04 '13 at 12:04