(CKEditor 是著名的 HTML 编辑器,IBM、Oracle、Adobe 等都在用。CKEditor 创建于 2003 年,其前身为 FCKEditor,在 2009 年的时候把“F”去掉了,更名为 CKEditor。其开源协议是基于 GPL, LGPL 和 MPL 的。官方网站:http://ckeditor.com/。请参见:CKEditor/FCKEditor 使用-CKeditor 3.0.1 快速教程(含插入图片)。ITPOW编辑注)
FCKeditor 的官方网站:http://www.fckeditor.net
一、程序瘦身:
下载下来的 FCKEditor2.6 中,针对我们使用的编程语言很多文件我们不需要
根目录下:editor 目录;fckconfig.js;fckeditor.asp;fckeditor.js;fckstyles.xml;fcktemplates.xml 这几个保留,其余的全部去除
子目录下:editorfilemanagerconnectors 目录中把 asp 目录留下 ( 上传用什么方法就留下什么 ),其余的方法目录 [php、aspx 等目录 ] 删除 ( 注意留下 test.html 和 uploadtest.html)
editorlang 语言目录把 en.js;zh.js;zh-cn.js 留下,其余全部删除
二、程序配置:
1、默认语言:
打开 fckconfig.js 文件 ( 相对 FCKeditor 文件夹,以下同 ),把自动检测语言改为不检测,把默认语言改为简体中文:
FCKConfig.AutoDetectLanguage = false;
FCKConfig.DefaultLanguage = 'zh-cn';
FCKConfig.TabSpaces = 1; // 在编辑器中是否可以是否 TAB 键 0 不可用 1 为可用
2、字体列表:
打开 fckconfig.js 文件,在字体列表中添加常用的“宋体;黑体;隶书;楷体 _GB2312”
FCKConfig.FontNames = ' 宋体 ; 黑体 ; 隶书 ; 楷体 _GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana';
编辑器域内默认的显示字体为 12px,想要修改可以通过修改样式表来达到要求,打开 /editor/css/fck_editorarea.css,把 body, td 下的 font-size:14px 即可
3、文件上传:
FCKeditor 的文件管理程序在 filemanager 文件夹中,又分为浏览 (browser) 和上传 (upload) 两种。浏览是指浏览服务器文件并可以选择,也可以上传本地文件至服务器;上传是指快速上传 (QuickUpload),在窗口中点“上传”选项卡打开就是,跟我们使用的 UBB 编辑器有点相似,选择本地文件后上传就行。
也就是说 FCKeditor 中有一个文件浏览,有两个文件上传,而这些设置有些在一个文件中,有的则在多个文件中。比较复杂,改动比较多,我们再分几个小点儿来说。
①打开和关闭文件浏览和上传功能:
fckconfig.js,以下内容设为 true 为开,false 则为关。
文件浏览和浏览中上传功能:
FCKConfig.LinkBrowser = false;
FCKConfig.ImageBrowser = false;
FCKConfig.FlashBrowser = false;
文件快速上传功能:
FCKConfig.LinkUpload = true;
FCKConfig.ImageUpload = true;
FCKConfig.FlashUpload = true;
editor/filemanager/connectors/asp/config.asp
ConfigIsEnabled = False // 表示文件浏览关闭
ConfigIsEnabled = True // 表示文件快速上传打开
②文件上传:
editorfilemanagerconnectorsaspconfig.asp
ConfigUserFilesPath = "/userfiles/" // 上传的路径设置
我的文件上传目录在根目录下面,就照以上设置。如果在本地测试这个网站在虚拟目录 test 中,则应该设置为:ConfigUserFilesPath = "/test/userfiles/"
③把默认语言 php 改成 asp
fckconfig.js
var _FileBrowserLanguage = 'asp'; // asp | aspx | cfm | lasso | perl | php | py 需要什么改成什么
var _QuickUploadLanguage = 'asp'; // asp | aspx | cfm | lasso | perl | php | py
④可以自己加上重定义文件名的程序
4、表单调用:
asp 调用方法:
<!--#include file="FCKEditor/fckeditor.asp" -->
<%
Dim oFCKeditor ' 定义变量
Set oFCKeditor = New FCKeditor ' 类的初始化
oFCKeditor.BasePath="FCKeditor/" ' 定义路径(这是根路径:/FCKeditor/)
oFCKeditor.ToolbarSet="Default" ' 定义工具条(默认为:Default;Default 为完整、Basic 为精简)
oFCKeditor.Width="100%" ' 定义高度(默认高度:200)
oFCKeditor.Height=350 ' 输入框的初始值
oFCKeditor.Value="" ' 输入框初始值
oFCKeditor.Create "FCKeditor1"
%>
js 调用方法:
<script src="FCKeditor/FCKeditor.js"></script>
<script type="text/javascript">
var oFCKeditor = new FCKeditor('Content');
oFCKeditor.BasePath = 'FCKeditor/';
oFCKeditor.ToolbarSet = 'Basic';
oFCKeditor.Width = '100%';
oFCKeditor.Height = '350';
oFCKeditor.Value = '';
oFCKeditor.Create();
</script>
5、输入框值获取
Request.Form("FCKeditor1")