加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php调用ckeditor?怎么调用ckeditor

发布时间:2020-12-13 20:26:41 所属栏目:PHP教程 来源:网络整理
导读:怎么调用ckeditor呢,下面小编来给大家总结一处利用php调用ckeditor编辑器与js调用ckeditor的方法吧,其它脚本调用方法大致一样了。 PHP调用FCKeditor, 将FCKeditor放在网站根目录,在PHP文件里面,包含fckeditor.php文件. 在网页中需要放置该编辑器的地方插入下

怎么调用ckeditor呢,下面小编来给大家总结一处利用php调用ckeditor编辑器与js调用ckeditor的方法吧,其它脚本调用方法大致一样了。

PHP调用FCKeditor,将FCKeditor放在网站根目录,在PHP文件里面,包含fckeditor.php文件.

在网页中需要放置该编辑器的地方插入下面代码即可调用:

  1. <?php 
  2.  //包含fckeditor类 
  3.  include("fckeditor/fckeditor.php") ; 
  4.  //创建一个FCKeditor,表单名称为 jzleditor 
  5.  $oFCKeditor = new FCKeditor("jzleditor"); 
  6.  //设置编辑器路径 
  7.  $oFCKeditor->BasePath = "fckeditor/"
  8.  $oFCKeditor->ToolbarSet = "Default";//工具按钮 
  9.  $oFCKeditor->Value =$cont//;设置初始内容 
  10.  $oFCKeditor->Width="100%"//设置它的宽度 
  11.  $oFCKeditor->Height="550px"//设置它的高度 
  12.  $oFCKeditor->Create(); 
  13. ?> 

输入内容,提交后,在处理的文件中通过$_POST["jzleditor"]来取得输入的内容

js调用FCKeditor

CKEDITOR的使用很简单,先download CKEDITOR 3.6.1(默认是PHP版的),然后在调用页面的head中,写下如下两段js,代码如下:

  1. <script type="text/javascript" src="ckeditor/ckeditor.js"></script> 
  2. <script type="text/javascript">                                                                    window.onload = function() 
  3.         { 
  4.          CKEDITOR.replace( "content" ); 
  5.         }; 
  6. </script> 

注意,这里的content是<textarea>的名称,如下所示:

<textarea name="content">ddd</textarea>如果是3.6.2版本,该语句可能要写成:

<textarea name="content" class="ckeditor">ddd</textarea>

版本差异造成的问题,请大家在运行时注意这个问题,在下一个页面根据name值content获取相应的值.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读