contenteditable and non button elements

前端 未结 4 1896
心在旅途
心在旅途 2021-02-09 23:32

I can easily do execcommand on a contenteditable selection if using a button. However using any other element fails.

http://jsbin.com/atike/edit

Why is this and

4条回答
  •  离开以前
    2021-02-09 23:50

    Most, if not all, of the WYSIWYG editors out there use an iframe element in order to not lose the selection. Another approach, although I haven't tried it, would be to store each selection made on that page after the mouseup event triggers.

    Take a look at this page about Midas, Gecko's built-in rich text editor.

提交回复
热议问题