六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 119|回复: 0

FCK学习笔记(二)

[复制链接]

升级  16.67%

17

主题

17

主题

17

主题

秀才

Rank: 2

积分
75
 楼主| 发表于 2013-1-29 07:33:26 | 显示全部楼层 |阅读模式
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 | brFCKConfig.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.JSFCK对象,对其动态设置
²        获取 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);  
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表