user782104 user782104 - 1 month ago 9
Javascript Question

How to change the editor size of CKEditor?

Since it is a textarea , i tried cols="50" in html attribute but it does not work.

Also , i found the answer from the previous question . He said i can do this by adding

CKEDITOR.instances.myinstance.resize(1000, 900);
however , the size still have not changed.

Here is the code i attempted, thank you

Updated

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script src="../plugin/jquery-1.6.1.min.js"></script>
<script src="../plugin/jquery.validate.min.js"></script>
<script type="text/javascript" src="../plugin/ckeditor/ckeditor.js"></script>

<script>
$(document).ready(function(){
$("#addlist").validate();
var editor = CKEDITOR.replace('editor1');
var div = document.getElementById('editor');
editor.resize($(div).width(),'900');
});
</script>
</head>
<body>
<form method="post" action="confirm.php">
<p><br />
<div id="editor">
<textarea id="editor1" name="editor1">
</div>
<? if (isset($_GET['file']))
{$filepath=$_GET['file'];
require_once("../template/".$filepath);}?> </textarea>
</p>
</br>
File Name </br>
<b>(Naming Without .html e.g. MyTemplate1) :</b>
</br>
<input id="tname" name="tname" class="required" />

<input type="submit" />

</p>
</form>
</body>
</html>

Answer

try following

To achieve this, use the resize function to define the dimensions of the editor interface, assigning the window a width and height value in pixels or CSS-accepted units.

// Set editor width to 100% and height to 350px.
editor.resize( '100%', '350' )

While setting the height value, use the isContentHeight parameter to decide whether the value applies to the whole editor interface or just the editing area.

// The height value now applies to the editing area.
editor.resize( '100%', '350', true )

http://docs.cksource.com/CKEditor_3.x/Howto/Editor_Size_On_The_Fly

Comments