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

首頁 > 語言 > JavaScript > 正文

JS操作Fckeditor的一些常用方法(獲取、插入等)

2024-05-06 15:44:39
字體:
來源:轉載
供稿:網(wǎng)友

javascript獲取和設置FCKeditor內容

利用Javascript取和設FCKeditor值也是非常容易的,如下:

// 獲取編輯器中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); // 第二個參數(shù)為:true|false,是否以所見即所得方式設置其內容。此方法常用于"設置初始值"或"表單重置"哦作。

插入內容到 FCK 編輯器:

oEditor.InsertHtml("html"); // "html"為HTML文本

檢查 FCK 編輯器內容是否發(fā)生變化:

oEditor.IsDirty();

在 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();

= FCKConfig.BasePath + 'plugins/'
// FCKConfig.Plugins.Add( 'placeholder', 'en,it' ) ;

去掉//后,就相當于把placeholder這個插件功能加上了,fckeditor的插件文件都在/editor/plugins/文件夾下分類按文件夾放置的,對于fckeditor2.0來說,里面有兩個文件夾,也就是有兩個官方插件,placeholder這個文件夾就是我們剛才加上去的,主要用于多參數(shù)或單參數(shù)自定義標簽的匹配,這個在制作編輯模板時非常管用,要想看具體實例的話,大家可以去下載acms 這個系統(tǒng)查看學習,另一個文件夾tablecommands就是編輯器里的表格編輯用到的了。當然,如果你想制作自己其它用途的插件,那就只要按照 fckeidtor插件的制作規(guī)則制作完放置在/editor/plugins/下就行,然后再在fckeidtor.js里再添加 FCKConfig.Plugins.Add('Plugin Name',',lang,lang');就可以了。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 凯里市| 阳高县| 浠水县| 林西县| 当雄县| 犍为县| 洮南市| 万荣县| 新乡县| 六枝特区| 政和县| 玛沁县| 偏关县| 英吉沙县| 额济纳旗| 崇明县| 南通市| 舒兰市| 道真| 镇巴县| 漯河市| 祁门县| 沿河| 任丘市| 忻城县| 朝阳区| 封丘县| 汉川市| 基隆市| 老河口市| 乌兰浩特市| 普定县| 额敏县| 伊宁市| 团风县| 陵川县| 许昌县| 广宁县| 彝良县| 定日县| 油尖旺区|