javascript - 如何更改CKEditor的编辑器大小?

标签 javascript jquery html ckeditor

因为它是一个 textarea ,我在 html 属性中尝试了 cols="50"但它不起作用。

另外,我从上一个问题中找到了答案。他说我可以通过添加来做到这一点。 CKEDITOR.instances.myinstance.resize(1000, 900); 但是,大小仍然没有改变。

这是我尝试的代码,谢谢。

已更新

<!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>

最佳答案

尝试关注

为此,请使用 resize定义编辑器界面尺寸的函数,以像素或 CSS 接受的单位为窗口分配宽度和高度值。

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

在设置高度值时,使用 isContentHeight 参数来决定该值是适用于整个编辑器界面还是仅适用于编辑区域。

// 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

关于javascript - 如何更改CKEditor的编辑器大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9990157/

相关文章:

javascript - if (xmlhttp.readyState==4 && xmlhttp.status==200) 在 AJAX 中不执行

javascript - 使用 HTML 和 PHP 的动态表

javascript - 将 d3.nest rollup 应用于嵌套饼图(以改变饼图的大小)

php - javascript/php - 将 amazon awis 示例从 php 移植到 javascript

javascript - Dropzone 在 init 函数上添加 id 并排序

html - 出于 SEO 的目的,如何将 JSON-LD 面包屑模式添加到我的网站导航中

javascript - 取标签内容

javascript - NextJS : Reload iFrame from another component

javascript - jQuery - 每 x 秒向下滚动一次,然后滚动到顶部

javascript - 从页面中删除所有 JavaScript