I'm trying to use FCKeditor's JavaScript API. All methods work except for Focus(). I'm probably minterpreting something.
I have a button on the page next to the editor is. When the user clicks that button, a string is inserted at the cursor in the editor. I would like the focus to remain in the editor after this insertion, and the insertion cursor (the blinking vertical line) to stay where it was before the insertion. Here is my script:
function InsertAtFCKCursor(strInsertion) {
var oEditor = FCKeditorAPI.GetInstance('FCKInput');
oEditor.InsertHtml(strInsertion);
oEditor.Focus();
}
The insertion works, but the editor doesn't reclaim focus. In order to continue typing in the editor, the use must click in the text again. That's what I'm trying to avoid by calling the Focus() method.
What am I missing?
Any tips will be apreciated.
Slava
I have a button on the page next to the editor is. When the user clicks that button, a string is inserted at the cursor in the editor. I would like the focus to remain in the editor after this insertion, and the insertion cursor (the blinking vertical line) to stay where it was before the insertion. Here is my script:
function InsertAtFCKCursor(strInsertion) {
var oEditor = FCKeditorAPI.GetInstance('FCKInput');
oEditor.InsertHtml(strInsertion);
oEditor.Focus();
}
The insertion works, but the editor doesn't reclaim focus. In order to continue typing in the editor, the use must click in the text again. That's what I'm trying to avoid by calling the Focus() method.
What am I missing?
Any tips will be apreciated.
Slava
Re: Focus() method fails in JavaScript API
Here is what I came up with, works so far in IE7 and FF3.
var oEditor = FCKeditorAPI.GetInstance("InstanceName");
oEditor.StartEditor();
oEditor.SetData("<p>HTML content</p>");
oEditor.Focus();
Hope this helps.