全球主机交流论坛

标题: 用js给fckeditor赋值的办法 [打印本页]

作者: fesite    时间: 2014-9-16 18:28
标题: 用js给fckeditor赋值的办法
虽然用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) ;
}
来源:yoyo blog




作者: 悠悠    时间: 2014-9-17 10:28
不错,支持下。




欢迎光临 全球主机交流论坛 (http://bbs.cuwww.com/) Powered by Discuz! X3.2