当前位置:K88软件开发文章中心编程全书编程全书01 → 文章内容

获取和设置FCKeditor中的内容

减小字体 增大字体 作者:佚名  来源:翔宇亭IT乐园  发布时间:2019-1-3 0:59:45

:2012-02-24 09:45:15

FCKeditor是一款非常优秀的在线HTML编辑器,功能强大,支持在线编辑HTML文件,上传图片和文件等功能。关于FCKeditor的安装与配置你可以在本站中进行搜索或在百度等搜索引擎中进行搜索一下即可。本文仅讲解如何设置和获取FCKeditor中的内容。

获取FCKeditor中的内容常有两种需求:(1)获取带HTML格式符的内容;(2)获取纯文本不含HTML格式符的内容,下面直接给出源代码。

// 获取编辑器中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) ;
}
 


获取和设置FCKeditor中的内容