发布于2026-07-22 阅读(0)
扫一扫,手机访问
在FCKeditor的开发中,经常需要与编辑器实例进行交互,比如获取或设置其内容。下面这三个函数就是最常用的API调用,直接复制到你的项目里就能用,省去每次手写重复代码的麻烦。
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) ;
}
三个函数分别对应:获取HTML内容、获取纯文本内容、设置编辑器内容。参数EditorName就是你在页面上初始化FCKeditor时指定的那个实例名称。注意getEditorHTMLContents返回的是经过XHTML规范化的代码,而getEditorTextContents直接取innerText,会丢掉所有HTML标签。设置内容时用SetHTML,直接传入字符串即可。
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
正版软件
正版软件
正版软件
正版软件
正版软件
1
2
3
7
8