Getting a handle to an FCKEditor Editor Instance
Posted March 17th, 2009 in FCKEditor
FCKEditor is an in-browser WYSIWYG HTML editor written in Javascript. There are times when you need to interact with the FCKEditor API; in order to use the API you need to first get a handle to the instance of the editor. This post shows how to do this; I have posted this code previously as part of another post but need to easily find it so have dedicated it to its own post.
If the instance name of the FCKEditor was 'html' then you can get a handle in Javascript like so:
var oEditor = FCKeditorAPI.GetInstance('html');
At that stage you can call any of the API functions, assign event handlers etc to the oEditor variable.
For example, to insert some HTML at the current insertion point (or overwrite the existing HTML if some is selected) you can call the InsertHtml function like so:
oEditor.InsertHtml("<p>hello world</p>");
A full list of the API functions can be found in the FCKeditor Javascript API documentation.
If the Javascript code is being run from a popup window, then you can get a handle to the instance in the parent window like this:
var oEditor = window.opener.FCKeditorAPI.GetInstance('html');
I post an FCKEditor post in the Javascript section of this blog roughly every 10 days, and will look at some of the API functions in detail over the next few posts. Be sure to subscribe to my RSS feed (details below) so you don't miss out.
Related posts:
- Get the HTML from an FCKEditor instance (Sunday, March 29th 2009)
- Insert HTML into FCKEditor (Friday, February 13th 2009)
- Using the FCKEditor HTML Editor with PHP (Wednesday, August 20th 2008)

Comments
blog comments powered by Disqus