Check documentation for the latest version of dhtmlxSuite Setting/Getting the Editor's Content DHTMLX Docs

Setting/Getting the Editor's Content

Setting the content

To set the content of a dhtmlxEditor object, use the setContent method:

Setting the content for the editor

var myEditor = new dhtmlXEditor({
    parent: "editorObj"
});
 
myEditor.setContent("Type some text here");

Related sample:  Set / get content


To set the initial content, you can also use the "content" parameter of the editor's constructor:

var myEditor = new dhtmlXEditor({
    parent: "editorObj",
    content:"Type some text here" });

Related sample:  Object API init

Loading the content from external resource

To populate the editor with content from some external resource, use the setContentHTML method:

Setting the external content for the editor

var myEditor = new dhtmlXEditor({
    parent: "editorObj"
});
 
myEditor.setContentHTML("common/editor/content.html");

Related sample:  Load content via ajax


To set the initial content, you can also use the "contentHTML" parameter of the editor's constructor:

var myEditor = new dhtmlXEditor({
    parent: "editorObj",
    contentHTML:"common/editor/content.html" });

Related sample:  Object API init

Getting the content

To get the current content of the editor, use the getContent method:

var content = myEditor.getContent();
alert(content);

Related sample:  Set / get content

Back to top