posts - 0,  comments - 20,  trackbacks - 0
http://www.diybl.com/course/4_webprogram/php/phpjs/2008410/109250.html
FCKeditor 是一个十分强大的网页文本编辑器,它支持多种脚本编程语言(包括 PHP)和支持多国语言。

    FCKeditor 截至 2008年4月6日,其最新版本是 2.6RC,RC 就是 Release Candidate,修订后的候选版本,很可能作为该版本的稳定版在未来发布。目前的最新的稳定版(Latest Stable)是 2.5.1。我们可以到他的官方网站上去下载 http://www.FCKeditor.net 合适的版本,开源、免费的。

    本文介绍 PHP 中的配置方法,其他语言的配置方法和它是基本一样的。

    〇、假设网站的目录为:
    \website_root
      \index.php
      \FCKeditor

    一、调用FCKeditor 的两种方法

    1、通过创建实例来调用

      在 index.php 文件中,调用它的代码,把下面的代码加在需要编辑器的地方:
      <Form name="frm1">
      <?php
        //引用FCKeditor.php这个文件,基本的类和数据结构都在这里
        include_once("FCKeditor/fckeditor.php");
        //创建FCKeditor对象的实例。myFCKeditor即提交后,接收数据页面 $_POST[''myFCKeditor'']使用
        $FCKeditor=new FCKeditor(''myFCKeditor'');
        //FCKeditor所在的位置,这里它的位置就是''FCKeditor'' 文件夹
        $FCKeditor->BasePath=''./FCKeditor/'';
        //工具按钮设置
        $FCkeditor->ToolbarSet=''Default'';
        //设置它的宽度
        $FCKeditor->Width=''100%'';
        //设置它的高度
        $FCKeditor->Height=''300px'';
        //生成
        $FCkeditor->Create();
      ?>
      </Form>

    2、通过 IFRAME 调用

    <Form name="frm1">
      <INPUT name="myFCKeditor" id="myFCKeditor" style="DISPLAY: none" type=hidden>
      <INPUT id="myFCKeditor___Config" style="DISPLAY: none" type=hidden>
      <IFRAME id="myFCKeditor___Frame" src="FCKeditor/editor/fckeditor.html?InstanceName=myFCKeditor&amp;Toolbar=Default" frameBorder=0 width=100% scrolling=no height=300>
      </IFRAME>
    </Form>

    注意:name="myFCKeditor" 和 IFRAME 中 InstanceName=myFCKeditor 的“myFCKeditor”必须相同。

    其实,用 IFRAME 调用和用第一种方法本质是完全一样的!不信的话,请在用浏览器打开网站上的 index.php 文件,然后查看“源代码”,就是本 IFRAME 调用的代码。所以推荐通过创建实例来调用。

    3、当用 Javascript 来获得内容的时候是不是发现得不到内容,如:
    <script>
      <input type=button onclick="alert(document.all.frm1.myFCKeditor.value);" value="GetHtml">
    </script>
    你会发现弹谈出的窗口没内容。

    我们可以通过下面的代码来获得它的内容:

    <script>
      function getContentValue()
      {
        var oEditor = FCKeditorAPI.GetInstance(''myFCKeditor'');
        var acontent = oEditor.GetXHTML();
        return acontent;
      }
    </script>
    <input type=button onclick="alert(getContentValue());">

    二、配置一些文件

    1、fckconfig.js的配置

    (1)工具按钮设置

    查找 FCKConfig.ToolbarSets["Default"],这里有很多按钮,下面我们将对他们详细介绍

    EditSource 显示HTML源代码
    StrikeThrough 删除线
    Save 保存
    NewPage 新建空白页面
    Superscript 上标
    Subscript 下标
    Preview 预览
    JustifyLeft 左对齐
    Cut 剪切
    Copy 复制
    Paste 粘贴
    JustifyCenter 居中对齐
    JustifyRight 右对齐
    JustifyFull 两端对齐
    PasteText 纯文本粘贴
    InsertOrderedList 自动编号
    PasteWord 来自Word的粘贴
    InsertUnorderedList 项目符号
    Print 打印
    Outdent 减少缩进
    SpellCheck 拼写检查
    Indent 增加缩进
    Find 查找
    ShowTableBorders 显示表格线
    Replace 替换
    ShowDetails 显示明细
    Undo 撤销
    Form 添加Form动作
    Redo 还原
    Checkbox 复选框
    SelectAll 全选
    Radio 单选按钮
    RemoveFormat 去除格式
    Input 单行文本框
    Link 插入/编辑 链接
    Textarea 滚动文本框
    RemoveLink 去除连接
    Select 下拉菜单
    Anchor 锚点
    Button 按钮
    Image 插入/编辑 图片
    ImageButton 图片按钮
    Table 插入/编辑 表格
    Hidden 隐藏
    Rule 插入水平线
    Zoom 显示比例
    SpecialChar 插入特殊字符
    FontStyleAdv 系统字体
    Un

posted on 2008-09-11 16:00 Documents 阅读(303) 评论(0)  编辑  收藏 所属分类: FCKeditor

只有注册用户登录后才能发表评论。


网站导航:
 
<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

留言簿

文章分类

文章档案

J2EE

搜索

  •  

最新评论