Javascript擷取FCKeditor内容:
一般寫法:
v ar oEditor = FCKeditorAPI.GetInstance(‘content’);
var content = oEditor.GetXHTML(true);
一、用javascript取 FCKeditor值:
1. 擷取編輯器中HTML内容:
function getEditorHTMLContents(EditorName){
var oEditor= FCKeditorAPI.GetInstance(EditorName);
return(oEditor.GetXHTML(true));
}
2. 擷取編輯器中文字内容
function getEditorTextContents(EditorName){
var oEditor =FCKeditorAPI.GetInstance(EditorName);
return(oEditor.EditorDocument.body.innerText);
}
PS: 計算字元長度:
var content = FCKeditorAPI.GetInstance('pMsgContent').GetXHTML();//編輯器中 HTML内容
alert(content.strip().length); //長度
var ftxt=FCKeditorAPI.GetInstance('pMsgContent').EditorDocument.body.innerText; //編輯器中文字内容
alert(ftxt.strip().length); //長度
二、用javascript設定 FCKeditor值:
1. 設定編輯器中内容
function setEditorContents(EditorName,ContentStr){
varoEditror = FCKeditorAPI.GetInstance(EditorName);
oEditor.setHTML(ContentStr);
}