return focus to contenteditable after execCommand?

前端 未结 5 1775
臣服心动
臣服心动 2021-02-04 08:56

I have the following code demonstrating contenteditable property and a button that will inject bold text into the paragraph with contenteditable area. My question is how to retu

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-04 09:33

    If you're in an iframe, call focus() on the default view.

    myiframedocument.execCommand('Bold',false,null);
    myiframedocument.defaultView.focus();
    

提交回复
热议问题