首页 > 设计 > 网页设计 > 正文

获取和设置FCKeditor中的内容

2023-05-03 14:31:29
字体:
来源:转载
供稿:网友

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) ;
}

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表