2

我不知道如何安装CKeditor,我在网站上下载了编辑器,然后将以下代码放在我的头标签之间:

<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript">
    window.onload = function()
    {
        var oFCKeditor1 = new CKEDITOR('message');
        oFCKeditor1.ToolbarSet = 'Basic' ;
        oFCKeditor1.BasePath = "ckeditor/" ;
        oFCKeditor1.ReplaceTextarea() ;
    }
</script>

但是下面的行返回了这个错误:

未捕获的类型错误:对象不是函数

var oFCKeditor1 = new CKEDITOR('message');

任何想法 ?

4

2 回答 2

12

根据文档,包括 ckeditor.js 文件:

<head>
    <script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
</head>

编辑器对textarea元素进行操作,因此在您的身体某处创建一个:

<textarea id="editor1" name="editor1">&lt;p&gt;Initial value.&lt;/p&gt;</textarea>

然后在元素声明使用以下代码初始化编辑器textarea

<script type="text/javascript">
    CKEDITOR.replace( 'editor1' );
</script>
于 2013-03-05T11:35:11.383 回答
0

我在这个链接上写了一篇文章。也许它有助于在您的网页中包含 js 文件。你也可以使用 CKEditor CDN

<script src="https://cdn.ckeditor.com/4.9.2/standard/ckeditor.js"></script>

OR

<script src="CKEditor_file_path/ckeditor.js"/>

 After select textarea where you want to add CKEditor

 <textarea name="editor1" id="editor1" rows="10" cols="80">
           This Textarea Replaced By CKEditor.
  </textarea>

编写代码替换CKEditor中的textarea

<script>
      CKEDITOR.replace( 'editor1' );
</script>

"editor1" 是 textarea 的名称,更多信息可以查看这个博客

http://besticoder.com/how-to-use-ckeditor-in-your-website-for-user-input/

于 2018-05-25T03:39:59.303 回答