FCKeditor在线编辑器工具栏中有好多工具都不需要,所以在具体开发中要修改工具栏,即去掉一些不必要的工具,具体步骤如下:
1)FCKeditor在线编辑器有一个主配置文件fckconfig.js(原本就已存在),我们通过修改这个配置文件来实现修改工具栏。但我们一般不会直接在fckconfig.js上做修改,而是创建一个新的config.js(需要我们自己创建)来覆盖fckconfig.js。它俩的存放路径如下:
config.js中的代码如下:
FCKConfig.ToolbarSets["myself"] = [
['Style','FontFormat','FontName','FontSize'],
['TextColor','BGColor'],
['ShowBlocks','-','About']
];
2)新建一个JavaScript1.jsp,在其中调用新的配置文件config.jsp,同时设置工具栏的名称为myself,代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
<title>通过JavaScript语言调用</title>
<!-- 引入外部的js文件 -->
<script type="text/javascript" src="fckeditor/fckeditor.js">
</script>
</head>
<body>
<h1>通过JavaScript语言调用</h1>
<!-- 调用FCKeditor在线文本编辑器 -->
<script type="text/javascript">
var oFCKeditor = new FCKeditor('FCKeditor1');
oFCKeditor.BasePath = "/myFCKeditortest/fckeditor/";
//配置CustomConfigurationsPath属性
oFCKeditor.Config["CustomConfigurationsPath"]="/myFCKeditortest/fckeditor/co nfig.js";
//设置属性Toolbarset
oFCKeditor.ToolbarSet="myself";
oFCKeditor.Create();
</script>
</body>
</html>
最后将项目发布到服务器,并在浏览器访问
JavaScript1.jsp。
一个非常简洁的自定义工具栏就生成了,当然你也可以根据自己的需求在config.js中进行编码来实现各种各样的工具栏。