Javascript TinyMCE对焦位置错误

Javascript TinyMCE对焦位置错误,javascript,tinymce,focus,editor,Javascript,Tinymce,Focus,Editor,我试着把注意力集中在编辑的内容上。它将焦点放在内容的开头,但应该放在内容的后面。你能建议我如何把焦点位置移到课文的末尾吗 <html> <body> <textarea id="mytextarea"> The focus will appear before this text. Should be after. </textarea> <script> tinymce.init({

我试着把注意力集中在编辑的内容上。它将焦点放在内容的开头,但应该放在内容的后面。你能建议我如何把焦点位置移到课文的末尾吗

<html>
<body>
    <textarea id="mytextarea">
      The focus will appear before this text. Should be after.
    </textarea>
<script>
    tinymce.init({ 
        selector: '#mytextarea',
        menubar: false,
    });

    setTimeout(function() {
        tinymce.execCommand('mceFocus');
    }, 2000)
</script>
</body>
</html>

焦点将显示在此文本之前。应该在后面。
tinymce.init({
选择器:“#mytextarea”,
梅努巴:错,
});
setTimeout(函数(){
tinymce.execCommand('mceFocus');
}, 2000)

以下是TinyMCE init中的工作示例,您可以添加以下内容:

setup: function (editor) {
    editor.on('init', function () {
        editor.focus();
        editor.selection.select(editor.getBody(), true);
        editor.selection.collapse(false);
    });
}
这会将光标移动到内容的最末端

(注意:请不要重复发布您的问题…当有人要求澄清时,最好更新您原来的帖子)

可能重复的问题