百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>网页制作> 修改增加fck编辑按钮 功能方法
分享文章到:

修改增加fck编辑按钮 功能方法

发布时间:01/14 来源: 浏览: 关键词:

第一步:在toolbar中添加功能按钮

fckconfig.js:fckconfig.toolbarsets[“default”] 中添加按钮名称
fckconfig.toolbarsets["default"] = [
['bold','italic','-','about', 'mydiy']
] ;

第二步:

为按钮添加中文名称和英文名称

zh-cn.js:为你的按钮起个中文名字
mydiy : “我的自定义按钮"

en.js:为你的按钮起个英文名字
mydiy:"mydiybutton"

第三步:在toolbar中显示该按钮

fckeditorcode_gecko.js(fckeditorcode_ie.js):
查找:

case 'newpage':b=new fcktoolbarbutton('newpage',fcklang.newpage,null,null,true,null,4);break;


在break后插入你的代码

比如case 'mydiy':b=new fcktoolbarbutton('mydiy',fcklang.mydiy,null,null,false,true,50);(这个50是按钮的显示图片,要让你的自定义按钮显示为插入图片那个按钮的图片,可以填入37)
这样就可以在toolbar中显示你的按钮了

第四步:定义按钮功能原型

ckeditorcode_gecko.js(fckeditorcode_ie.js):

查找:

var fcknewpagecommand=function(){this.name='newpage';};
fcknewpagecommand.prototype.execute=function(){fckundo.saveundostep();fck.sethtml('');fckundo.typing=true;};
fcknewpagecommand.prototype.getstate=function(){return fck_tristate_off;};

定义功能原型:(这里直接复newpage的实现代码放到后面,然后进行修改)

比如:var fckmydiycommand=function(){this.name='mydiy';};fckmydiycommand.prototype.execute=function(){ 这里写你所需要执行的代码或者函数,比如alert("i am here !");};fckmydiycommand.prototype.getstate=function(){return 0;};
将上面代码插入到查找内容之后。

第五步:按钮功能实例化:

ckeditorcode_gecko.js(fckeditorcode_ie.js):

查找:

case 'newpage':b=new fcknewpagecommand();break;


功能实例化:

case 'mydiy':b=new fckmydiycommand();break;


将上面代码插入到查找内容之后。

ok,这样就可以在为fckeditor加上自定义的按钮了。

如果要为按钮加上快捷键,可以在fckconfig.js中:fckconfig.keystrokes = []加上
[ ctrl + 71 /*g*/, 'mydiy' ],

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有2人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板