Javascript TINYMCE设置焦点。。。这是行不通的

Javascript TINYMCE设置焦点。。。这是行不通的,javascript,focus,tinymce,set,Javascript,Focus,Tinymce,Set,我试过了 tinyMCE.execInstanceCommand("content", "mceFocus"); 我试过了 tinyMCE.execCommand('mceFocus', false, "content"); 它们似乎都不起作用:-(嗯,我也遇到了同样的问题。但我相信这取决于代码的执行位置。以下是我迄今为止找到的各种链接: 但我通过以下方式解决了我的问题,它可能不适用于您的问题: this.focus(); this.tinymce.execCommand('mceFoc

我试过了

tinyMCE.execInstanceCommand("content", "mceFocus");
我试过了

tinyMCE.execCommand('mceFocus', false, "content");

它们似乎都不起作用:-(

嗯,我也遇到了同样的问题。但我相信这取决于代码的执行位置。以下是我迄今为止找到的各种链接:


但我通过以下方式解决了我的问题,它可能不适用于您的问题:

this.focus();

this.tinymce.execCommand('mceFocus',false,'yourtinymcetextraeaid_goes_here');

这段代码应用于tiny_mce_src.js->InsertHorizontalRule中,只是为了让您了解范围



希望有帮助。

有一种比前面建议的代码更简单的方法。初始化tinymce时,有一个选项可以设置配置参数。只需确保设置了自动对焦选项

var editorOptions = {
    script_url: "/scripts/tinymce/tiny_mce.js",
    theme: "advanced",
    entities: "",
    theme_advanced_toolbar_location: "top",
    theme_advanced_toolbar_align: "left",
    theme_advanced_statusbar_location: "bottom",
    theme_advanced_resizing: true,
    content_css: "/styles/site.css",
    template_external_list_url: "lists/template_list.js",
    external_link_list_url: "lists/link_list.js",
    external_image_list_url: "lists/image_list.js",
    media_external_list_url: "lists/media_list.js",
    theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,bullist,numlist,|,undo,redo,|,link,unlink,anchor,image,help",
    theme_advanced_buttons2: "",
    theme_advanced_buttons3: "",
    theme_advanced_buttons4: "",
    width: "640",
    height: "220",
    auto_focus: "body2"
};

我在Safari 5.0.4、Firefox 3.6.13、MacOSX 10.6.6上的Google Chrome 10.0和Win XP上的IE 8上使用了TinyMCE 3.4和两个“高级”Tiny的实例。在所有情况下,焦点都会转移到指定的实例。您能详细说明何时调用这些实例,TinyMCE、Browser、OS的哪个版本吗?这是迄今为止最好的响应!应该是我的真实答案。触发焦点与自动聚焦不同。这可能在TinyMCE被初始化时起作用,但仅此而已。这并不是一个明确的问题回答老年退休金计划的问题。