读书人

CKEDITOR 如何实现自定义按钮添加html

发布时间: 2013-03-28 10:20:24 作者: rapoo

CKEDITOR 怎么实现自定义按钮添加html代码

CKEDITOR.plugins.add(
"html",
{
requires:["dialog"],

init:function (a)
{

a.addCommand("html", new CKEDITOR.dialogCommand("html"));
a.ui.addButton(
"Html",
{
label:"插入html",
command:"html",
icon:this.path + "html.jpg"
});

}


}

);
添加自定义按钮 我想知道点击这按钮时候,在光标停留的地方会自动添加<div>你好</div> 这段html代码.请高手指点,谢谢! CKEDITOR 自定义按钮 添加
[解决办法]
(function(){
//按下按钮运行的js
var a= {
exec:function(editor){
var rules='<div id="rules" style="position:relative; background:#CCC; border:1px solid #000; top:0px; left:0px; ;width:128px ; height: 1206px; background-image: url(images/rules.png); ">1</div>';
CKEDITOR.instances.content.insertHtml(rules);
}
},
//按钮配置
b='rules';
CKEDITOR.plugins.add(b,{
init:function(editor){
editor.addCommand(b,a);
editor.ui.addButton('rules',{
label:'插入标尺',
icon: this.path + 'untitled.png',
command:b
});
}
});
})();


结贴吧

读书人网 >Java相关

热点推荐