这篇文章介绍了JavaScript获取FCK编辑器信息的实例代码
有需要的朋友可以参考一下
复制代码 代码如下:
function getEditorContents(){
var oEditor = FCKeditorAPIGetInstance("content");
alert(oEditorGetXHTML(true));
}
//向编辑器插入指定代码
function insertHTMLToEditor(codeStr){
var oEditor = FCKeditorAPIGetInstance("content");
if (oEditorEditMode==FCK_EDITMODE_WYSIWYG){
oEditorInsertHtml(codeStr);
}else{
return false;
}
}
//统计编辑器中内容的字数
function getLength(){
var oEditor = FCKeditorAPIGetInstance("content");
var oDOM = oEditorEditorDocument;
var iLength ;
if(documentall){
iLength = oDOMbodyinnerTextlength;
}else{
var r = oDOMcreateRange();
rselectNodeContents(oDOMbody);
iLength = rtoString()length;
}
alert(iLength);
}
//执行指定动作
function ExecuteCommand(commandName){
var oEditor = FCKeditorAPIGetInstance("content") ;
oEditorCommandsGetCommand(commandName)Execute() ;
}
//设置编辑器中内容
function SetContents(codeStr){
var oEditor = FCKeditorAPIGetInstance("content") ;
oEditorSetHTML(codeStr) ;
}