在文章修改模块 , 给 fckeditor 赋值的几点注意

      首先,处理查询取得要修改的文章内容字符串:

 

        由于,文章中包含了多种标签,因此在页面显示时必须先将字符串中的 引号, 回车, 换行 进行转义,否则会造成编辑器创建失败或者文章内容超出编辑区。

        jsp 用此方法转换

       <%
         Information news = (Information)request.getAttribute("news");
         String context = news.getContext();
         String tempContext = context.replace("'","/'");
         tempContext = context.replaceAll("/r/n","<br>");                
       %>

 

转换后,再将值赋给fckeditor

      <script type="text/javascript">
                                        var oFCKeditor = new FCKeditor('context');
                                        oFCKeditor.BasePath='resources/fckeditor/';
                                        oFCKeditor.Height='450px';
                                        oFCKeditor.Width='800px';
                                        oFCKeditor.ToolbarSet='DefaultNoForm';
                                        oFCKeditor.Value = ' <%=tempContext%>' ;//默认值
                                        oFCKeditor.Create();
                                    </script>

 

至此,就能修改之前用 fckeditor 编辑过的内容,而不至于处理乱容时常常导致js错误,或html语法错误。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值