Ckeditor没有为我工作?

时间:2014-04-11 18:28:47

标签: php jquery html codeigniter ckeditor

我想使用ckeditor 4.3.4来codeigniter 2.1.4我试着在jsbin中开始测试它,它没用。我该怎么办?

如何在codeigniter 2.1.4中使用ckeditor 4.3.4? 如何安装ckeditor基本?

DEMO: http://jsbin.com/lacekiyu/1/edit

代码:

<html>
    <head>
<script src="www.ckeditor.com/apps/ckeditor/4.3.4/ckeditor.js"></script>
            <script>
                CKEDITOR.replace( 'editor1' );
            </script>
    </head>
    <body>
        <form>
            <textarea name="editor1" id="editor1" rows="10" cols="80">
                This is my textarea to be replaced with CKEditor.
            </textarea>
        </form>
    </body>
</html>

2 个答案:

答案 0 :(得分:1)

1)。将您的ckeditor js链接更改为正确的网址:http://ckeditor.com/apps/ckeditor/4.3.4/ckeditor.js。 2)。添加body onload事件,它将起作用。

<html>
  <head>
  <script src="http://ckeditor.com/apps/ckeditor/4.3.4/ckeditor.js"></script>
  <script>
    function init() {  
      CKEDITOR.replace( 'editor1' );
    }
  </script>
  </head>
  <body onload="init()">
    <form>
      <textarea name="editor1" id="editor1" rows="10" cols="80">
        This is my textarea to be replaced with CKEditor.
      </textarea>
    </form>
  </body>
</html>

答案 1 :(得分:0)

您需要更正对 CKEditor 脚本的引用,并将CSS类ckeditor添加到textarea

<head>
  <script src="http://ckeditor.com/apps/ckeditor/4.3.4/ckeditor.js"></script>
</head>
<body>
    <form>
        <textarea class="ckeditor" name="editor">
            This is my textarea to be replaced with CKEditor.
        </textarea>
    </form>
</body>

您可以在服务器上托管CKEditor JavaScript。假设它存储在您的Web根目录中的文件夹中,名为assets(例如public_html/assets)并且加载了URL帮助程序,您可以在视图中引用它:

<script src="<?php echo base_url("assets/ckeeditor.js"); ?>"></script>