FCKEditor – how to access the HTML content from JavaScript?

Imagine you have a form in which you use FCKEditor as an inline HTML editor. So, inside script tag you have this:

var oFCKeditor = new FCKeditor('body_html');
oFCKeditor.BasePath = "A_PATH_TO_FCKEDITOR";
oFCKeditor.ToolbarSet = "Basic";
oFCKeditor.Create();

As you know, this creates a textarea with id set to ‘body_html’ and make it look like an inline HTML editor.

Going forward, you would like to receive the HTML code that represents the content of this textarea, and that you want to do this in JavaScript. In order to do that you need to follow FCKEditor API, so do somethink like this:

FCKeditorAPI.GetInstance('body_html').GetHTML(true);

Maybe it’s obvious but it took my a while to find out how to do this…

Previous Post
Next Post