FCKEDITOR 相關(guān)函數(shù)介紹
更新時(shí)間:2010年07月26日 14:30:25 作者:
FCKeditorAPI是FCKeditor加載后注冊(cè)的一個(gè)全局對(duì)象,利用它我們就可以完成對(duì)編輯器的各種操作。
獲取FCK的實(shí)例
FCKeditorAPI是FCKeditor加載后注冊(cè)的一個(gè)全局對(duì)象,利用它我們就可以完成對(duì)編輯器的各種操作。
在當(dāng)前頁(yè)獲得 FCK 編輯器實(shí)例:
var Editor = FCKeditorAPI.GetInstance('InstanceName');
從 FCK 編輯器的彈出窗口中獲得 FCK 編輯器實(shí)例:
var Editor = window.parent.InnerDialogLoaded().FCK;
從 框架頁(yè)面的子框架中獲得其它子框架的 FCK 編輯器實(shí)例:
var Editor = window.FrameName.FCKeditorAPI.GetInstance('InstanceName');
從頁(yè)面彈出 窗口中獲得父窗口的 FCK 編輯器實(shí)例:
var Editor = opener.FCKeditorAPI.GetInstance('InstanceName');
FCK獲取焦點(diǎn)
獲 取焦點(diǎn)是否在FCK中:
oEditor.HasFocus
FCK獲取焦點(diǎn):
oEditor.Focus();// 獲取焦點(diǎn)
獲取和設(shè)置FCK的內(nèi)容
獲得 FCK 編輯器的內(nèi)容:
oEditor.GetXHTML(formatted); // formatted 為:true|false,表示是否按HTML格式取出。
設(shè)置 FCK 編輯器的內(nèi)容:
oEditor.SetHTML("content", false); // 第二個(gè)參數(shù)為:true|false,是否以所見(jiàn)即所得方式設(shè)置其內(nèi)容。
插入內(nèi)容到 FCK 編輯器:
oEditor.InsertHtml("html"); // "html"為HTML文本
檢查 FCK 編輯器內(nèi)容是否發(fā)生變化:
oEditor.IsDirty();
// 獲取編輯器中HTML內(nèi)容
function getEditorHTMLContents(EditorName) {
var oEditor = FCKeditorAPI.GetInstance(EditorName);
return(oEditor.GetXHTML(true));
}
// 獲取編輯器中文字內(nèi)容
function getEditorTextContents(EditorName) {
var oEditor = FCKeditorAPI.GetInstance(EditorName);
return(oEditor.EditorDocument.body.innerText);
}
// 設(shè)置編輯器中內(nèi)容
function SetEditorContents(EditorName, ContentStr) {
var oEditor = FCKeditorAPI.GetInstance(EditorName) ;
oEditor.SetHTML(ContentStr) ;
}
FCK的事件處理
FCK 定義有OnComplete,OnBlur和OnFocus等事件,這樣就可以使用事件的處理函數(shù)完成相應(yīng)的處理。
FCK添加事件處理 函數(shù)的方法是:fckInstance.Events.AttachEvent( EventName, function)
代碼
//FCKeditor 加載完成后做處理的方法
function FCKeditor_OnComplete( editorInstance )
{
editorInstance.Events.AttachEvent( 'OnBlur' , FCKeditor_OnBlur ) ;
editorInstance.Events.AttachEvent( 'OnFocus', FCKeditor_OnFocus ) ;
}
function FCKeditor_OnBlur( editorInstance )
{
//失去焦點(diǎn)收起工具欄
editorInstance.ToolbarSet.Collapse() ;
}
function FCKeditor_OnFocus( editorInstance )
{
editorInstance.ToolbarSet.Expand() ;
}
FCKeditorAPI是FCKeditor加載后注冊(cè)的一個(gè)全局對(duì)象,利用它我們就可以完成對(duì)編輯器的各種操作。
在當(dāng)前頁(yè)獲得 FCK 編輯器實(shí)例:
var Editor = FCKeditorAPI.GetInstance('InstanceName');
從 FCK 編輯器的彈出窗口中獲得 FCK 編輯器實(shí)例:
var Editor = window.parent.InnerDialogLoaded().FCK;
從 框架頁(yè)面的子框架中獲得其它子框架的 FCK 編輯器實(shí)例:
var Editor = window.FrameName.FCKeditorAPI.GetInstance('InstanceName');
從頁(yè)面彈出 窗口中獲得父窗口的 FCK 編輯器實(shí)例:
var Editor = opener.FCKeditorAPI.GetInstance('InstanceName');
FCK獲取焦點(diǎn)
獲 取焦點(diǎn)是否在FCK中:
oEditor.HasFocus
FCK獲取焦點(diǎn):
oEditor.Focus();// 獲取焦點(diǎn)
獲取和設(shè)置FCK的內(nèi)容
獲得 FCK 編輯器的內(nèi)容:
oEditor.GetXHTML(formatted); // formatted 為:true|false,表示是否按HTML格式取出。
設(shè)置 FCK 編輯器的內(nèi)容:
oEditor.SetHTML("content", false); // 第二個(gè)參數(shù)為:true|false,是否以所見(jiàn)即所得方式設(shè)置其內(nèi)容。
插入內(nèi)容到 FCK 編輯器:
oEditor.InsertHtml("html"); // "html"為HTML文本
檢查 FCK 編輯器內(nèi)容是否發(fā)生變化:
oEditor.IsDirty();
復(fù)制代碼 代碼如下:
// 獲取編輯器中HTML內(nèi)容
function getEditorHTMLContents(EditorName) {
var oEditor = FCKeditorAPI.GetInstance(EditorName);
return(oEditor.GetXHTML(true));
}
// 獲取編輯器中文字內(nèi)容
function getEditorTextContents(EditorName) {
var oEditor = FCKeditorAPI.GetInstance(EditorName);
return(oEditor.EditorDocument.body.innerText);
}
// 設(shè)置編輯器中內(nèi)容
function SetEditorContents(EditorName, ContentStr) {
var oEditor = FCKeditorAPI.GetInstance(EditorName) ;
oEditor.SetHTML(ContentStr) ;
}
FCK的事件處理
FCK 定義有OnComplete,OnBlur和OnFocus等事件,這樣就可以使用事件的處理函數(shù)完成相應(yīng)的處理。
FCK添加事件處理 函數(shù)的方法是:fckInstance.Events.AttachEvent( EventName, function)
代碼
//FCKeditor 加載完成后做處理的方法
function FCKeditor_OnComplete( editorInstance )
{
editorInstance.Events.AttachEvent( 'OnBlur' , FCKeditor_OnBlur ) ;
editorInstance.Events.AttachEvent( 'OnFocus', FCKeditor_OnFocus ) ;
}
function FCKeditor_OnBlur( editorInstance )
{
//失去焦點(diǎn)收起工具欄
editorInstance.ToolbarSet.Collapse() ;
}
function FCKeditor_OnFocus( editorInstance )
{
editorInstance.ToolbarSet.Expand() ;
}
相關(guān)文章
UEditor 默認(rèn)字體和字號(hào)的修改方法
這篇文章主要介紹了UEditor 默認(rèn)字體和字號(hào)的修改方法,需要的朋友可以參考下2017-03-03在kindEditor中獲取當(dāng)前光標(biāo)的位置索引的實(shí)現(xiàn)代碼
一直在用KindEditor,今天要用到光標(biāo)的位置,然后就gg一下辦法,后來(lái)發(fā)現(xiàn)這東西的編輯區(qū)域居然是iframe里面的一個(gè)body,不是textarea/input,后來(lái)就翻開(kāi)了他的代碼看,發(fā)現(xiàn)有個(gè)insertHtml2011-11-11fckediter javascript事件函數(shù)代碼
fckediter javascript事件函數(shù)代碼,另外fckeditor的可以擴(kuò)展性不錯(cuò),大家可以學(xué)習(xí)下,具體的代碼,可以參考腳本之家以前發(fā)布的文章。2009-12-12asp.net CKEditor和CKFinder的應(yīng)用
CKEditor和CKFinder在ASP.NET中的應(yīng)用,需要的朋友可以參考下。2010-01-01Prism 代碼高亮修改不包含 Code 標(biāo)簽的支持
在 WordPress 中加入了百度的 UEditor 編輯器后,由于自帶的代碼插件在使用時(shí)只會(huì)在代碼外層加入 pre 標(biāo)簽,下面給出解決方法,需要的朋友可以參考下2017-03-0319款Javascript富文本網(wǎng)頁(yè)編輯器
19款javascript富文本編輯器。也許你還有興趣查看15個(gè)基于Web的HTML編輯器和6款所見(jiàn)即所得(WYSIWYG)的在線Web編輯器。2010-11-11Office文檔在線編輯的一個(gè)實(shí)現(xiàn)方法
因?yàn)轫?xiàng)目的關(guān)系,研究了一下Office的在線編輯功能,寫(xiě)出來(lái)共享一下。2010-06-06通過(guò)Fckeditor把圖片上傳到獨(dú)立圖片服務(wù)器的方法
大部分網(wǎng)站的后臺(tái),都是把圖片上傳到本地服務(wù)器上,但圖片也消耗很多帶寬,門(mén)戶網(wǎng)站都有單獨(dú)的圖片服務(wù)器,怎么實(shí)現(xiàn)呢?2011-05-05