Ckeditor 编辑更改宽度

Ckeditor 编辑更改宽度,ckeditor,Ckeditor,我想更改Ckeditor的宽度和高度,但无法更改。 请知道我想在调用CKeditor时更改它,我不想在config.js中硬编码它 底层代码不起作用,你有什么建议 var editor = CKEDITOR.replace('editorToday', { toolbar : [ { name: 'document', items : [ 'Preview' ] },

我想更改Ckeditor的宽度和高度,但无法更改。 请知道我想在调用CKeditor时更改它,我不想在config.js中硬编码它

底层代码不起作用,你有什么建议

var editor = CKEDITOR.replace('editorToday',
          {


            toolbar :
                [
                    { name: 'document', items : [ 'Preview' ] },
                    { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
                    { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','Scayt' ] },
                    { name: 'insert', items : [ 'Image','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'] },
                            '/',
                    { name: 'styles', items : [ 'Styles','Format' ] },
                    { name: 'basicstyles', items : [ 'Bold','Italic','Strike','-','RemoveFormat' ] },
                    { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote' ] },
                    { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
                    { name: 'tools', items : [ 'Maximize','-','About' ] }

                ]

            });


CKEDITOR.instances.editor.resize(500, 400);

我建议使用括号表示法以及使用实例的ID:

试用

CKEDITOR.instances['editorToday'].resize(500400)

试试这个:

 var editor = CKEDITOR.replace('editorToday',
      {


        toolbar :
            [
                { name: 'document', items : [ 'Preview' ] },
                { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
                { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','Scayt' ] },
                { name: 'insert', items : [ 'Image','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'] },
                        '/',
                { name: 'styles', items : [ 'Styles','Format' ] },
                { name: 'basicstyles', items : [ 'Bold','Italic','Strike','-','RemoveFormat' ] },
                { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote' ] },
                { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
                { name: 'tools', items : [ 'Maximize','-','About' ] }

            ],
        width: "400px",
        height: "500px"

        });

以下内容摘自

步骤1 创建一个新的ASP.NET网站,并将其命名为Demo_应用程序

步骤2 从此处下载Ckeditor,并将Ckeditor添加到应用程序的根文件夹中

步骤3 调用.aspx页面中的Ckeditor脚本,如下所示

<script type="text/javascript" src="scripts/jquery-1.4.1.min.js"></script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="ckeditor/adapters/jquery.js"></script>

步骤4 将Ckeditor文本框添加到id为txtCkEditor的.aspx文件中

<asp:TextBox ID="txtCkEditor" runat="server" TextMode="MultiLine"></asp:TextBox>

第五步。 调用下面的JavaScript函数更改Ckeditor文本框区域的默认宽度

<script type="text/javascript">
    $(function () {  
      CKEDITOR.replace('<%=txtCkEditor.ClientID %>');
      CKEDITOR.config.width = 200;
    });
</script>

$(函数(){
CKEDITOR.替换(“”);
CKEDITOR.config.width=200;
});
步骤6
测试您的应用程序。

只需使用以下命令:

CKEDITOR.replace('descCKEditor',{ width: "800px",height: "500px"}); 

我尝试了你的代码,但如果我打开firebug检查错误,它就不起作用了,页面仍处于“加载”状态……页面中的某些内容没有加载,这可能会阻止js正常执行。我尝试了你的代码,但使用了这个,它工作得很好:CKEDITOR.instances.editorToday.resize(500400);另外,代码很可能失败,因为CKE加载是异步的。这意味着当调用
.resize(…)
时,CKEditor尚未加载,因此无法调整自身大小。不建议使用依赖于链接的答案,您能否将答案汇总并将链接作为参考?与两年前提供的简单答案相比,这太复杂了。实际上,在尝试了很多东西之后,我唯一的选择就是使用CKEDITOR.config.width=200,谢谢!试试下面@user3258189所建议的
CKEDITOR.config.width=200
——这是我在谷歌搜索数小时后唯一有效的方法。