繁体   English   中英

JS中的特殊字符,如何使用“ /”字符

[英]Special Characters in JS, how to use “/” character

我已经安装了vbulletin 4.2.0,并在本文的编辑器中添加了一个特殊按钮;

http://www.vbulletinguru.com/2012/add-a-new-toolbar-button-to-ckeditor-tutorial/

我想做的就是使用此按钮添加语法突出显示代码。

当我使用下面的代码时,它工作正常;

CKEDITOR.plugins.add( 'YourPluginName',
{
    init: function( editor )
    {
        editor.addCommand( 'SayHello',
            {
                exec : function( editor )
                {    
                        editor.insertHtml( "Hello from my plugin" );
                }
            });
        editor.ui.addButton( 'YourPluginName',
        {
            label: 'My Button Tooltip',
            command: 'SayHello',
            icon: this.path + 'YourPluginImage.png'
        } );
    }
} );  

所以我将此代码更改为此,因为我想添加如下所示的特定文本;

CKEDITOR.plugins.add( 'DKODU',
{
    init: function( editor )
    {
        editor.addCommand( 'SayHello',
            {
                exec : function( editor )
                {
                        editor.insertHtml( '[kod=delphi][/kod]' );
                }
            });
        editor.ui.addButton( 'DKODU',
        {
            label: 'My Button Tooltip',
            command: 'SayHello',
            icon: this.path + 'star.png'
        } );
    }
} );

更新代码后,当我按下按钮时,什么都没有发生,我与google和这个网站进行了核对,但我无法弄清楚,我认为我用一些特殊字符弄错了,但是我找不到问题所在。

如果我在发布此问题时犯了一些错误,请原谅我,也请原谅我的英语不好,谢谢。

就像我们在C / C ++或所有其他语言中一样,使用'\\'转义'/'

所以,

editor.insertHtml( '[kod=delphi][\/kod]' );

谢谢大家的回答,我解决了这个

var baslangic="[kod=delphi]";
var bitis="[/kod]";
CKEDITOR.plugins.add( 'DKODU',
{
    init: function( editor )
    {
        editor.addCommand( 'DKODU',
            {
                exec : function( editor )
                {    
                 editor.insertHtml(baslangic);
                 editor.insertHtml('');
                 editor.insertHtml(bitis);
                }
            });
        editor.ui.addButton( 'DKODU',
        {
            label: 'Delphi Kodu Ekle',
            command: 'DKODU',
            icon: this.path + 'star.png'
        } );
    }
} );  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM