zl程序教程

您现在的位置是:首页 >  前端

当前栏目

JavaScript获取FCK编辑器信息的具体方法

JavaScript编辑器 获取 信息 具体方法
2023-06-13 09:15:03 时间
复制代码代码如下:

   functiongetEditorContents(){
   varoEditor=FCKeditorAPI.GetInstance("content");
   alert(oEditor.GetXHTML(true));
}
//向编辑器插入指定代码
functioninsertHTMLToEditor(codeStr){
   varoEditor=FCKeditorAPI.GetInstance("content");
   if(oEditor.EditMode==FCK_EDITMODE_WYSIWYG){
    oEditor.InsertHtml(codeStr);
   }else{
    returnfalse;
   }
}
//统计编辑器中内容的字数
functiongetLength(){
   varoEditor=FCKeditorAPI.GetInstance("content");
   varoDOM=oEditor.EditorDocument;
   variLength;
   if(document.all){
    iLength=oDOM.body.innerText.length;
   }else{
    varr=oDOM.createRange();
    r.selectNodeContents(oDOM.body);
    iLength=r.toString().length;
   }
   alert(iLength);
}
//执行指定动作
functionExecuteCommand(commandName){
   varoEditor=FCKeditorAPI.GetInstance("content");
   oEditor.Commands.GetCommand(commandName).Execute();
}
//设置编辑器中内容
functionSetContents(codeStr){
   varoEditor=FCKeditorAPI.GetInstance("content");
   oEditor.SetHTML(codeStr);
}