首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java相关 >

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

2013-03-28 
CKEDITOR 怎么实现自定义按钮添加html代码 CKEDITOR.plugins.add(html,{requires:[dialog],init:funct

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
            });
        }
    });
})();


结贴吧

热点排行