1
我需要帮助解决这个错误:如何修复错误“Selection.addRange()”?
是Selection.addRange()合并现有的范围和指定范围内的 被弃用,并将在M58被删除,四月左右 2017年见https://www.chromestatus.com/features/6680566019653632更多的行为细节。
我不能编辑,或破坏我的网站的元素。
我需要帮助解决这个错误:如何修复错误“Selection.addRange()”?
是Selection.addRange()合并现有的范围和指定范围内的 被弃用,并将在M58被删除,四月左右 2017年见https://www.chromestatus.com/features/6680566019653632更多的行为细节。
我不能编辑,或破坏我的网站的元素。
从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.