TINYMCE 设定焦点...只是行不通

发布于 2024-10-22 04:10:08 字数 205 浏览 1 评论 0原文

我已经尝试过,

tinyMCE.execInstanceCommand("content", "mceFocus");

我已经尝试过,

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

但似乎都不起作用:-(

I've tried

tinyMCE.execInstanceCommand("content", "mceFocus");

I've tried

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

None of them seem to work :-(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七度光 2024-10-29 04:10:08

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

http://tinymce.moxiecode .com/forum/viewtopic.php?id=8238

http ://tinymce.moxiecode.com/forum/viewtopic.php?pid=91307#p91307

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

this.focus( );

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

此代码应用于tiny_mce_src.js -> InsertHorizo​​ntalRule,这样您就可以了解范围。

希望有帮助。

Well, I was stuck in the same problem. But I believe it depends where you execute the code. Here are various links that I've found so far:

http://tinymce.moxiecode.com/forum/viewtopic.php?id=8238

http://tinymce.moxiecode.com/forum/viewtopic.php?pid=91307#p91307

But I solved my issue the following, and it might not apply to yours:

this.focus();

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

This code was applied inside the tiny_mce_src.js -> InsertHorizontalRule, just so you can have an idea of the scope.

Hope that helps.

终陌 2024-10-29 04:10:08

有一种比之前建议的代码更简单的方法。初始化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"
};

There is an even simpler way than the previous suggested code. When you initialize tinymce, there is an option to set the configuration parameters. Just make sure that you set the AUTOFOCUS option.

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"
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文