首先在js文件中配置工具栏的按钮,Defaul中的按钮很齐全,去掉不需要用的就可以了
fck.config.js
FCKConfig.ToolbarSets["Custom"] = [ ['FontFormat','FontName','FontSize','TextColor','BGColor','Bold','Italic','Underline','StrikeThrough'], '/', ['Undo','Redo','Cut','Copy','Paste','-','-','RemoveFormat'], ['Outdent','Indent'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'], ['Link','Unlink'], ['Image','Flash','Table','Smiley','-','-','Source'] ]; FCKConfig.ToolbarSets["Image"] = [ ['Image'] ];
Custom的按钮跟Javaeye的编辑框是一样的
我习惯使用自定义标签的方式
<FCK:editor instanceName="context" toolbarSet="Custom" width="480" height="300"> <jsp:body> <FCK:config CustomConfigurationsPath="${pageContext.request.contextPath}/fck.config.js" /> </jsp:body> </FCK:editor>
用Javascript验证输入内容,由于是自定义标签,document.getElementById("context")是错误的。
应该调用FCKeditorAPI的方法
var fEditor=FCKeditorAPI.GetInstance("Context"); var context=fEditor.GetXHTML();