inserthtml

execCommand insertHTML breaks stored window.getSelection()

瘦欲@ 提交于 2019-12-17 10:07:37
问题 When using methods of selecting text and restoring selected text in a page, I have found that running execCommand('insertHTML... inbetween causes the stored selection to break. This is a sample of how the text is selected and restored. // Get Selection var sel = window.getSelection().getRangeAt(0); // Clear Selections window.getSelection().removeAllRanges(); // Restore Selection window.getSelection().addRange(sel) This works fine, however once you run execCommand('insertHTML.. the selections

execCommand insertHTML breaks stored window.getSelection()

江枫思渺然 提交于 2019-11-27 09:52:18
When using methods of selecting text and restoring selected text in a page, I have found that running execCommand('insertHTML... inbetween causes the stored selection to break. This is a sample of how the text is selected and restored. // Get Selection var sel = window.getSelection().getRangeAt(0); // Clear Selections window.getSelection().removeAllRanges(); // Restore Selection window.getSelection().addRange(sel) This works fine, however once you run execCommand('insertHTML.. the selections endOffset sets itself to the same value as the selections startOffset Is there a reason for this? More