在JSP中使用CKEditor网页编辑器

为了在我的一个项目使用CKEditor网页编辑器,我开始了寻找应用之法。

我下载了ckeditor_4.3.3_standard和ckeditor-java-core-3.5.3。

之前的版本和现在版本的使用好像不一样。

参考了《HTML编辑器FCKeditor使用详解》:

其版本是“FCKeditor 2.5.1(FCKeditor_2.5.1.zip)和FCKeditor.Java(FCKeditor-2.3.zip)”

发现不能使用。

然后我直接找到“http://nightly.ckeditor.com/14-04-02-06-05/standard/samples/”官方网站的使用说明。

其实ckeditor 4.0以后的编辑器使用javascript来写,可直接使用。

使用<script src="/ckeditor/ckeditor.js"></script>导入保存在根目录下的/ckeditor/ckeditor.js脚本,

然后在页面上使用如下代码即可(一定要使用class为ckeditor):

<textarea class="ckeditor" name="editor1"></textarea>
还可以使用Id:
<textarea cols="80" id="editor1" name="editor1" rows="10">
  
 </textarea>
 <script>
  
 // This call can be placed at any point after the
 // <textarea>, or inside a <head><script> in a
 // window.onload event handler.
  
 // Replace the <textarea id="editor"> with an CKEditor
 // instance, using default configurations.
  
 CKEDITOR.replace( 'editor1' );
  
 </script>

在项目做如下修改。

(1)将javascript脚本添加到页面中:

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

(2)删除之前的editor网页编辑器的内容,再适当地修改textarea的参数:

<OBJECT id="HTML" data="/acmhome/judge/editor.html" width="100%" height="360" type="text/x-scriptlet"></object>
<html:textarea property="answer" style="DISPLAY:none"></html:textarea>

删除第一行,修改第二行,将style的属性删除,其他保持不便。

(3)修改javascript函数调用

*删除原来有javascript函数调用:

<body  bgColor=white οnlοad="pageonloadM()" id="nicetabs">

<html:submit οnclick="bs();"><bean:message key="button.submit"/></html:submit>

*编写自己的javascript函数:

//初始化网页编辑器
function initEditor(){
var f = document.newproblemForm;
CKEDITOR.replace( f.description);
CKEDITOR.replace(f.input );
CKEDITOR.replace( f.output );
CKEDITOR.replace( f.hint );
}

*在网页加载时调用initEditor函数,如下:

<body  bgColor=white οnlοad="initEditor()" id="nicetabs">

 

**************

如果没有显示,那么应该是javascript脚本的标签放置的位置不对,网页不能加载进去,将它的代码放到body中也可以。

 

转载于:https://www.cnblogs.com/dranyu/p/3641485.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值