// 擷取編輯器中HTML內容
function getEditorHTMLContents(EditorName) {
var oEditor = FCKeditorAPI.GetInstance(EditorName);
return(oEditor.GetXHTML(true));
}
// 擷取編輯器中文字內容
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) ;
}
FCKeditorAPI是FCKeditor載入後註冊的一個全域對象,利用它我們就可以完成對編輯器的各種操作。
在當前頁獲得 FCK 編輯器執行個體:
var Editor = FCKeditorAPI.GetInstance('InstanceName');
從 FCK 編輯器的快顯視窗中獲得 FCK 編輯器執行個體:
var Editor = window.parent.InnerDialogLoaded().FCK;
從架構頁面的子架構中獲得其它子架構的 FCK 編輯器執行個體:
var Editor = window.FrameName.FCKeditorAPI.GetInstance('InstanceName');
從頁面快顯視窗中獲得父視窗的 FCK 編輯器執行個體:
var Editor = opener.FCKeditorAPI.GetInstance('InstanceName');
獲得 FCK 編輯器的內容:
oEditor.GetXHTML(formatted); // formatted 為:true|false,表示是否按HTML格式取出
也可用:
oEditor.GetXHTML();
設定 FCK 編輯器的內容:
oEditor.SetHTML("content", false); // 第二個參數為:true|false,是否以所見即所得 (WYSIWYG)方式設定其內容。此方法常用於"設定初始值"或"表單重設"哦作。
插入內容到 FCK 編輯器:
oEditor.InsertHtml("html"); // "html"為HTML文本
檢查 FCK 編輯器內容是否發生變化:
oEditor.IsDirty();
擷取焦點
oEditor.Focus();
在 FCK 編輯器之外調用 FCK 編輯器工具條命令:
命令列表如下:
DocProps, Templates, Link, Unlink, Anchor, BulletedList, NumberedList, About, Find, Replace, Image, Flash, SpecialChar, Smiley, Table, TableProp, TableCellProp, UniversalKey, Style, FontName, FontSize, FontFormat, Source, Preview, Save, NewPage, PageBreak,
TextColor, BGColor, PasteText, PasteWord, TableInsertRow, TableDeleteRows, TableInsertColumn, TableDeleteColumns, TableInsertCell, TableDeleteCells, TableMergeCells, TableSplitCell, TableDelete, Form, Checkbox, Radio, TextField, Textarea, HiddenField, Button,
Select, ImageButton, SpellCheck, FitWindow, Undo, Redo
使用方法如下:
oEditor.Commands.GetCommand('FitWindow').Execute();
轉自:http://www.cnblogs.com/yssoft/archive/2009/04/29/1446342.html