Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/453.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript JS中的特殊字符,如何使用/&引用;性格_Javascript_Character_Vbulletin - Fatal编程技术网

Javascript JS中的特殊字符,如何使用/&引用;性格

Javascript JS中的特殊字符,如何使用/&引用;性格,javascript,character,vbulletin,Javascript,Character,Vbulletin,我在vbulletin 4.2.0中添加了一个特殊的按钮,在这篇文章的编辑器中 我想做的是用这个按钮添加一个语法高亮代码 当我使用下面的代码时,它工作得很好 CKEDITOR.plugins.add( 'YourPluginName', { init: function( editor ) { editor.addCommand( 'SayHello', { exec : function( editor

我在vbulletin 4.2.0中添加了一个特殊的按钮,在这篇文章的编辑器中

我想做的是用这个按钮添加一个语法高亮代码

当我使用下面的代码时,它工作得很好

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'
        } );
    }
} );
当我按下按钮更新代码后,什么都没有发生,我与谷歌和这个网站进行了检查,但我无法找出它。我想我犯了一些特殊字符的错误,但我找不到问题所在


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

就像我们在C/C++或所有其他语言中做的那样,用“\”摆脱“/”

所以


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

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

如果我没记错的话,
/
不需要转义(在chrome中可以工作,我相信在其他浏览器中也可以)。亲爱的Hars,谢谢你的回复,我已经准备好尝试了,但没有成功。
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'
        } );
    }
} );