Fckeditor API 詳解

來源:互聯網
上載者:User

// 擷取編輯器中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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.