国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

網(wǎng)頁編輯器FCKEDITOR 的高級功能和常見問題的解決方法

2024-07-21 02:53:42
字體:
供稿:網(wǎng)友
FCKeditor是一個專門使用在網(wǎng)頁上屬于開放源代碼的所見即所得文字編輯器。它志于輕量化,不需要太復(fù)雜的安裝步驟即可使用。
 
它可和PHP、JavaScript、ASP、ASP.NET、ColdFusion、Java、以及ABAP等不同的編程語言相結(jié)合。FCK的配置和使用都很簡單,但是默認(rèn)的配置不能滿足所有的需求,所以我們需要了解一些FCK的高級功能。 

獲取FCK的實例 
FCKeditorAPI是FCKeditor加載后注冊的一個全局對象,利用它我們就可以完成對編輯器的各種操作。 
在當(dāng)前頁獲得 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獲取焦點 
獲取焦點是否在FCK中: 
oEditor.HasFocus 
FCK獲取焦點: 
oEditor.Focus();//獲取焦點 

獲取和設(shè)置FCK的內(nèi)容 
獲得 FCK 編輯器的內(nèi)容: 
oEditor.GetXHTML(formatted); // formatted 為:true|false,表示是否按HTML格式取出。 

設(shè)置 FCK 編輯器的內(nèi)容: 
oEditor.SetHTML("content", false); // 第二個參數(shù)為:true|false,是否以所見即所得方式設(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) 
代碼 
復(fù)制代碼代碼如下:

//FCKeditor加載完成后做處理的方法 
function FCKeditor_OnComplete( editorInstance ) 

editorInstance.Events.AttachEvent( 'OnBlur' , FCKeditor_OnBlur ) ; 
editorInstance.Events.AttachEvent( 'OnFocus', FCKeditor_OnFocus ) ; 

function FCKeditor_OnBlur( editorInstance ) 

//失去焦點收起工具欄 
editorInstance.ToolbarSet.Collapse() ; 

function FCKeditor_OnFocus( editorInstance ) 

editorInstance.ToolbarSet.Expand() ; 


注:相關(guān)教程知識閱讀請移步到編輯器頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 富阳市| 江川县| 丹棱县| 祁阳县| 徐闻县| 泾川县| 游戏| 鄢陵县| 双鸭山市| 肇源县| 汪清县| 祁门县| 霞浦县| 准格尔旗| 无为县| 张家港市| 霸州市| 波密县| 阳新县| 锦州市| 鄂尔多斯市| 连南| 宁明县| 勃利县| 雷州市| 三台县| 张北县| 镇江市| 上栗县| 静乐县| 六安市| 高邑县| 柏乡县| 渝中区| 江山市| 屯门区| 昆明市| 杭锦旗| 巴彦淖尔市| 北京市| 襄汾县|