Forum

Yampiz Forum

Sharing let knowledge Spreaded, Reading let spirits growth, Creative let culture extended, Let us
  • 禁止廣告文
  • 知識傳播
  • 閱讀
  • 心靈成長
  • 創作
  • 文化傳承
Forum Dictionary / Programming / 網頁/網站程式 / JavaScript /

從外部編輯 FCKEditor 的內容

New Subject
Random
Previous
Next
|
從外部編輯 FCKEditor 的內容

有些功能是自己想追加的,修改 FCKeditor 源碼又不是那麼的容易,所以都一直找不到合適的方法,今天總算找到了,鳴~淚奔

原來在 fckeditor 裡面編輯內容,是透過 fckeditor 外面的 button 來增加 fckeditor 編輯區的內容,也就是說在 fckeditor 外面有個 button,按下 button 就會 insert 一段 HTML。

所以就使用我們用來控制 Fckeditor 物件。

像是這樣
oFckeditor=FCKeditorAPI.GetInstance('InstanceName');

接著就可以用 InsertHtml 來增加一些 HTML
oFckeditor.InsertHtml('<div>外部加入的 HTML!!</div>');

另外還有控制 Fckeditor 捲軸的方法
EditorWindow.scrollTo(0,oFckeditor.EditorDocument.body.scrollHeight);

oFckeditor.EditorWindow 是 Fckeditor 裡面的 window
oFckeditor.EditorDocument 是 Fckeditor 裡面的 document
因此,一般 window 和 document 物件可以做到的,EditorWindow 和 EditorDocument 應該都可以做到唷 。

  • Keywords : oFckeditor, fckeditor, Fckeditor, button, EditorWindow, EditorDocument, 方法, 外面, window, document, InsertHtml, 透過, 編輯區, 編輯內容, 用來控制, 物件, 源碼, 淚奔, 控制, 捲軸
0 0
2009-03-18T07:45:14+0000

魚戀秋波 Neil Y.K. :

FCKeditorApi

最詳細的FCKeditorApi文檔默過於官方wiki提供的文檔了。

FCKeditorApi官方文檔地址:http://wiki.fckeditor.net/Developer's_Guide/Javascript_API

下面提供國內某網友的翻譯文檔,轉載地址:http://blog.imwebs.com/article.asp?id=322

FCK編輯器加載後,將會注冊一個全局的FCKeditorAPI對象。

FCKeditorAPI對象在頁面加載期間是無效的,直到頁面加載完成。如果需要交互式地知道FCK編輯器已經加載完成,可使用"FCKeditor_OnComplete"函數。

<scripttype="text/javascript">
functionFCKeditor_OnComplete(editorInstance){
FCKeditorAPI.GetInstance('FCKeditor1').Commands.GetCommand('FitWindow').Execute();
}
</script>

在當前頁獲得FCK編輯器實例:
varEditor=FCKeditorAPI.GetInstance('InstanceName');

從FCK編輯器的彈出窗口中獲得FCK編輯器實例:
varEditor=window.parent.InnerDialogLoaded().FCK;

從框架頁面的子框架中獲得其它子框架的FCK編輯器實例:
varEditor=window.FrameName.FCKeditorAPI.GetInstance('InstanceName');

從頁面彈出窗口中獲得父窗口的FCK編輯器實例:
varEditor=opener.FCKeditorAPI.GetInstance('InstanceName');

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

也可用:
oEditor.GetXHTML();

設置FCK編輯器的內容:
oEditor.SetHTML("content",false);//第二個參數為:true|false,是否以所見即所得方式設置其內容。此方法常用於"設置初始值"或"表單重置"哦作。

插入內容到FCK編輯器:
oEditor.InsertHtml("html");//"html"為HTML文本

檢查FCK編輯器內容是否發生變化:
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();

0 0
2009-09-10T19:04:55+0000


  • Now, you can post comments by Facebook Account when your Yampiz account was logout or unvariable. whatever, we suggest to post comment by Yampiz Account to get more bounds to join new events of Heyxu
Comment
 
Verify

Facebook Page

QR-Code and APP Launcher

User Guide
This Webpage

In those service tabs, "Scan QRCode, in mobile device" or "Click the button, in this device" to open webpage or APP-related operations.
QRCode
  • Auto Platform
    For better browsing experience, it will auto detects your device to display webpage.
  • Bug Report
    Tell us about the idea, problem and errors you found.
  • Comodo Secure
    The sensitive data transmission adopts by SSL-2048 authenticated encryption.
  • Copyright
    © 2009 YamPiz Digital Inc. & Jaby Group. All rights reserved.
  • Revised Version
    V2.2.061
    03 Aug 2023 (GMT+8)