Archive for June, 2006

Fckeditor doesn’t want to focus in Firefox? Solution

Posted on the June 8th, 2006 under Uncategorized by

FCKEditor is a nice free WYSIWYG editor, highly customizable. Occasionally, however, especially when used with a div that shows/hides or JavaScript doesn’t want to focus properly in Firefox. Here’s a way I found around about it.

function wakeUpFireFoxFckeditor()
{
var oEditor = FCKeditorAPI.GetInstance(‘myinstanceoffckeditor’) ;
try
{
oEditor.MakeEditable();
}
catch (e) {}
oEditor.Focus();
}

Just to add:

  1. It’s best to call FCKeditorAPI – in fact you’d get an error if you did – after the page is loaded. Hence it’s in a function. You could probably tie it to a body onload, or onclick=””, etc.
  2. Use the try/catch approach. IE complains that you are waking up Firefox, so this is just a way to gracefully make both of them happy.
  3. Focus for usability. More commands available at: http://wiki.fckeditor.net/Developer%27s_Guide/Javascript_API