我需要帮助来修复此错误:
The behavior that Selection.addRange() merges existing Range and the specified Range is deprecated and will be removed in M58, around April 2017. See https://www.chromestatus.com/features/6680566019653632 for more details.
我无法编辑或销毁我网站的元素。
最佳答案
来自this Github issue ,现在您必须调用removeAllRanges()
在将范围添加到您的选择之前:
selection = window.getSelection(); // Save the selection.
range = document.createRange();
range.selectNodeContents(elem);
selection.removeAllRanges(); // Remove all ranges from the selection.
selection.addRange(range); // Add the new range.
关于javascript - 如何修复错误 "Selection.addRange()"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43415498/