• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

JSP 页面中使用FCKeditor控件(js用法)

java 搞代码 4年前 (2022-01-05) 25次浏览 已收录 0个评论

FCKeditor是一个专门使用在网页上属于开放源代码的所见即所得文字编辑器。它志于轻量化,不需要太复杂的安装步骤即可使用。

它可和PHP、JavaScript、ASP、ASP.NET、ColdFusion、Java、以及ABAP等不同的编程语言相结合。“FCKeditor”名称中的“FCK” 是这个编辑器的作者的名字Frederico Caldeira Knabben的缩写。

FCKeditor控件请到官方网站下载http://www.fckeditor.net,本例主要用到FCKeditor_2.6.3.zip、fckeditor-java-demo-2.4.1.zip、fckeditor-java-2.4.1-bin.zip里面的一些内容,读者可以自行下载。

1. 解开压缩包FCKeditor_2.6.3.zip,将其中的fckeditor文件夹复制到WEB-INF下面,后面可以直接使用。

2. 在页面中使用FCKeditor有两种方式。

方式一:JavaScript的方式

(1)直接使用,见method1.html

<span><font size="2"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br><html><br><head><br><script type="text/javascript" src="fckedito<em style="color:transparent">来源gao.dai.ma.com搞@代*码网</em>r/fckeditor.js"></script><br></head><br><body><br>方法一:通过JavaScript来实现的实现编辑器导入<br><br><script type="text/javascript"><br>var oFCKeditor = new FCKeditor('FCKeditor1') ;<br>oFCKeditor.BasePath = "fckeditor/";<br>//oFCKeditor.BasePath   = "/FCKEditTest/fckeditor/";<br>oFCKeditor.Width="50%";<br>oFCKeditor.Height="400";<br>oFCKeditor.Value="initial value";<br>//oFCKeditor.ToolbarSet="Basic";<br>//默认是default<br>oFCKeditor.ToolbarSet="Default";<br>oFCKeditor.Create() ;<br></script><br><hr><br></body><br></html> </font></span><p><span><font size="2">(2)通过Textarea,祥见method2.html</font></span></p><pre class="prettyprint linenums"><span><font size="2"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br><html><br><head><br><script type="text/javascript" src="fckeditor/fckeditor.js"></script><br><script type="text/javascript"><br>window.onload=function(){<br>var oFCKeditor = new FCKeditor('MyTextarea') ;<br>oFCKeditor.BasePath = "fckeditor/"; //这里注意相对路径<br>//oFCKeditor.BasePath   = "/FCKEditTest/fckeditor/";<br>oFCKeditor.ReplaceTextarea();<br>}<br></script><br></head><br><body><br>方法二:通过Textarea来实现的实现编辑器导入<br><br><textarea rows="4" cols="60" name="MyTextarea">this is a value</textarea><br></body><br></html></font></span>
<p><strong><span><font size="2">方式二:在标签使用FCKeditor</font></span></strong></p><p><span><font size="2">在使用标签之前,需要搭建环境。将fckeditor-java-2.4.1-bin.zip包中的fckeditor-java-core-2.4.1.jar、commons-fileupload-1.2.1.jar、commons-io-1.3.2.jar、slf4j-api-1.5.2.jar以及包fckeditor-java-demo-2.4.1.zip中的slf4j-simple-1.5.2.jar复制到lib目录下,并构建环境。</font></span></p><p><span><font size="2">构建完后,就可以在JSP页面中进行使用。祥见页面method_jsp.jsp</font></span></p><pre class="prettyprint linenums"><span><font size="2"><%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><br><%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%><br><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br><html><br><head><br><title>method_jsp.jsp</title><br></head><br><body> <br>早些版本必需将fckeditor的Value属性必需指定对应的值,且值不能为空。<br>而此处版本是2.6.3,该问题已经解决。<br><FCK:editor instanceName="myEditor" basePath="/fckeditor"></FCK:editor><br></body><br></html></font></span>

以上就是JSP 页面中使用FCKeditor控件(js用法)的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:JSP 页面中使用FCKeditor控件(js用法)

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址