羊皮纸 服务
       
       
      分享
       
      羊皮纸论坛

      羊皮纸论坛

      分享让知识传播,阅读让心灵成长, 创作让文化传承,让我们共同努力。
      • 禁止广告文
      • 知识传播
      • 阅读
      • 心灵成长
      • 创作
      • 文化传承
      羊皮纸论坛目录 / 程式设计 / 网页/网站程式 / JavaScript /

      从外部编辑 FCKEditor 的内容

      发表新主题
      随机主题
      上个主题
      下个主题
      |
      从外部编辑 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 应该都可以做到唷 。

      • 关键字 : 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


      • 当您未登入羊皮纸时,可以利用脸书 Facebook 登入来发表回响。若使用羊皮纸会员身份发表回响则可获得经验值及虚拟金币,用来参加羊皮纸推出的活动。
      发表回响
       
      验证字串

      Facebook 粉丝专页

      QRCode 条码 & APP 连结

      说明
      本页网址

      在相关服务标签中,『扫描条码,在行动装置』或是『点击连结按钮,在本装置』中开启网页或是 APP 相关操作。
      QRCode