虽然用fckeditor很久了,但是对它并不熟悉,今天就碰到一个问题,就是如何通过js来对已经加载的fckeditor赋值,研究了半天也没搞定,后来我在网上看到了三个函数,写的真是太好了,拿过来和大家一块分享一下。
//获取编辑器中HTML内容
function getEditorHTMLContents(EditorName)
{
var oEditor = FCKeditorAPI.GetInstance(EditorName);
return(oEditor.GetXHTML(true));
}
//获取编辑器中文字内容
function getEditorTextContents(EditorName)
{
var oEditor = FCKeditorAPI.GetInstance(EditorName);
return(oEditor.EditorDocument.body.innerText);
}
//设置编辑器中内容
function SetEditorContents(EditorName, ContentStr)
{
var oEditor = FCKeditorAPI.GetInstance(EditorName) ;
oEditor.SetHTML(ContentStr) ;
}