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