Get formatted HTML from CKEditor

sslepian picture sslepian · Mar 14, 2010 · Viewed 56.1k times · Source

I'm using CKEditor in my web app, and I'm at a loss as to how to get the contents of the editor with HTML formatting.

var objEditor = CKEDITOR.instances["sectionTextArea"];
var q = objEditor.getData();

This will get me the text entered in CKEditor, without any markup.

However,

var q = objEditor.getHTML();

will return a null value. What am I doing wrong?

Answer

AlfonsoML picture AlfonsoML · Mar 17, 2010

getHTML isn't a method of a CKEditor object, so instead of null you should have a javascript error.

The method defined by the api is getData() if that doesn't work then you have some other problem in your code, try to use an alert to verify the contents at that moment.