1.针对不同的FCK写单独的配置文件,配置FCK
² 创建FCK时,配置如下:
function switchtxt()//我采用的textarea替换的方法 { var oFCKeditor = new FCKeditor('answ'); oFCKeditor.BasePath = "${pageContext.request.contextPath}/fckeditor/"; oFCKeditor.Config["CustomConfigurationsPath"]="${pageContext.request.contextPath}/admin/js/MyFCKConfig.js";//单独配置文件的路径 oFCKeditor.ReplaceTextarea();
² 项目根路径/admin/MyFCKConfig.js
FCKConfig.ToolbarSets["Default"] = [ ['Save','NewPage','Preview','-','Cut','Copy','Paste','PasteText','PasteWord','-','SpellCheck','-','Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],'/', ['Radio','Checkbox','TextField','-','Image','Table','Rule','SpecialChar','Subscript','Superscript'],'/', ['Bold','Italic','Underline','StrikeThrough','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyFull','-','OrderedList','UnorderedList','-','Outdent','Indent'], '/', // No comma for the last row. ] ; FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/office2003/' ; FCKConfig.EnterMode = 'br' ; // p | div | br FCKConfig.ShiftEnterMode = 'p' ;
只做了基本配置,可根据FCK下config.js,根据需要继续添加
2.FCK自动换行
转:网上找了半天的资料也没有找个相关的修改,偶尔看到CSS:word-break:break-all;可以实现换行,那么控制编辑区就可以控制换行了,马上找到fckeditor\editor\css\fck_editorarea.css文件进行修改
body, td { font-family: 宋体,黑体,隶书,楷体_GB2312,Arial, Verdana, Sans-Serif; font-size: 16px; width:750px;//编辑区大小 word-break:break-all;//自动换行 }
3.JS取FCK对象,对其动态设置
² 获取 fck编辑器的的对象
var oEditor=FCKeditorAPI.GetInstance('content');
² 用对象的方法来获取fckeditor的值
var content=oEditor.GetXHTML(true);
² 设置fckeditor的值
oEditor.SetHTML(content);
详细链接:http://caizg-126-com.iteye.com/blog/364131
3.JQuery 设置FCK
² 下载这个插件jquery.FCKEditor.rar
² 在页面头部加载js文件(根据实际情况修改相应路径)
<script src="../js/jquery.js" type=text/javascript></script> <script src="../js/jquery.FCKEditor.js" type=text/javascript></script> <script src="../fckeditor/fckeditor.js" type="text/javascript"></script>
² 初始化编辑器(根据实际情况修改相应路径)
$.fck.config = {path: '/这里是你的项目名称/fckeditor/', height: 400 ,toolbar:'Default'}; $('textarea#ncontent').fck(); //其中ncontent为页面你所绑定的textarea的id或name
² 取值
var getcontent = $.fck.content('ncontent', '');
² 赋值
var oEditor = FCKeditorAPI.GetInstance('ncontent'); oEditor.SetHTML(data.news_add.na_newscontent);