0

在版本 9 之前,我需要与 Internet Explorer 中的 getRangeAt() 方法等效的方法

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);
4

1 回答 1

0

document.selection.createRange(); 是在 IE<9 中创建范围对象的代码,等效于 IE>= 9 中使用的 getRangeAt 方法

于 2013-07-04T11:49:16.423 回答