Reputation: 1280
I've tried
tinyMCE.execInstanceCommand("content", "mceFocus");
I've tried
tinyMCE.execCommand('mceFocus', false, "content");
None of them seem to work :-(
Upvotes: 4
Views: 9756
Reputation: 106
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"
};
Upvotes: 4
Reputation: 1557
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.
Upvotes: 6