return focus to contenteditable after execCommand?

前端 未结 5 1783
臣服心动
臣服心动 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

    HTML:

    
    

    JavaScript:

    function doRichEditCommand(aName, aArg){
        getIFrameDocument('editorWindow').execCommand(aName,false, aArg);
        document.getElementById('editorWindow').contentWindow.focus()
    }
    

    Refer this may help you:

    https://developer.mozilla.org/en/Rich-Text_Editing_in_Mozilla

提交回复
热议问题