天天看點

FCKeditor 擷取編輯器中文字内容

// 擷取編輯器中HTML内容 

function getEditorHtmlContents(name,isClearP){

//擷取多文本編輯框的對象

   var oEditor = FCKeditorAPI.GetInstance(name);

   //擷取使用者輸入的内容

   var acontent = oEditor.GetXHTML();

  if(isClearP){

 //過濾掉多文本編輯框增加的<p></p>

 acontent=acontent.substr(3,acontent.length-7);

  }

   return acontent;

}

// 擷取編輯器中文字内容 

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

}