我想更改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);
答案 0 :(得分:17)
试试这个:
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 :(得分:1)
我建议使用括号表示法以及使用实例的ID:
尝试使用
CKEDITOR.instances ['editorToday']。resize(500,400);
答案 2 :(得分:1)
以下摘自How to change or set width of Ckediotr TextBox area using ASP .Net。
创建一个新的ASP.NET网站并将其命名为Demo_application。
从此处下载Ckeditor并将Ckeditor添加到应用程序的根文件夹中。
在.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>
将Ckeditor TextBox添加到id为txtCkEditor的.aspx文件中
<asp:TextBox ID="txtCkEditor" runat="server" TextMode="MultiLine"></asp:TextBox>
调用Below JavaScript函数来更改Ckeditor TextBox区域的默认宽度。
<script type="text/javascript">
$(function () {
CKEDITOR.replace('<%=txtCkEditor.ClientID %>');
CKEDITOR.config.width = 200;
});
</script>
测试您的应用程序。
答案 3 :(得分:0)
只需使用此:
CKEDITOR.replace('descCKEditor',{ width: "800px",height: "500px"});