一、FCKEditor简介。
FCKeditor 文本编辑程序具有与微软 Office 软件一样的功能。与之不同的是,FCKeditor 不需要用户安装任何形式的客户端,只需要打开页面即可进行在线文档操作。FCKeditor 程序非常精简但功能强大,在 Web2.0 时代成为网站建设者的开发利器。
二、关于FCKEditor的简单实例。
1、准备工作。
1)在FCKEditor官网上下载FCKeditor_2.6.6.zip、fckeditor-java-2.6-bin.zip和fckeditor-java-2.6-src.zip;
2)解压FCKeditor_2.6.6.zip,并将文件夹fckeditor添加到项目中的WebRoot目录下;
3)将以下的zip包添加到项目中的lib目录下。
fckeditor-java-core-2.6.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
slf4j-api-1.5.8.jar
slf4j-simple-1.5.8.jar
2、实例。
实例一:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>fck</title>
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
</head>
<body>
方法一:通过javascript来实习的编辑器导入<br>
<script type="text/javascript">
var oFCKeditor = new FCKeditor('FCKeditor1');
oFCKeditor.BasePath = "fckeditor/";
oFCKeditor.Width = "50%";
oFCKeditor.Height = "400";
oFCKeditor.value = "initial value";
oFCKeditor.ToolbarSet = "Default";
oFCKeditor.Create();
</script>
<hr>
</body>
</html>
<html>
<head>
<title>fck</title>
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
</head>
<body>
方法一:通过javascript来实习的编辑器导入<br>
<script type="text/javascript">
var oFCKeditor = new FCKeditor('FCKeditor1');
oFCKeditor.BasePath = "fckeditor/";
oFCKeditor.Width = "50%";
oFCKeditor.Height = "400";
oFCKeditor.value = "initial value";
oFCKeditor.ToolbarSet = "Default";
oFCKeditor.Create();
</script>
<hr>
</body>
</html>
实例二:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>fck</title>
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
<script type="text/javascript">
window.onload = function(){
var oFCKeditor = new FCKeditor('Textarea');
oFCKeditor.BasePath = "fckeditor/";
oFCKeditor.ReplaceTextarea();
}
</script>
</head>
<body>
方法二:通过Textarea来实习的编辑器导入<br>
<textarea rows="4" cols="60" name="Textarea">this is a value</textarea>
</body>
</html>
<html>
<head>
<title>fck</title>
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
<script type="text/javascript">
window.onload = function(){
var oFCKeditor = new FCKeditor('Textarea');
oFCKeditor.BasePath = "fckeditor/";
oFCKeditor.ReplaceTextarea();
}
</script>
</head>
<body>
方法二:通过Textarea来实习的编辑器导入<br>
<textarea rows="4" cols="60" name="Textarea">this is a value</textarea>
</body>
</html>
实例三:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri=" http://java.fckeditor.net" prefix="FCK" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>fck</title>
</head>
<body>
<FCK:editor instanceName="myEditor" basePath="/fckeditor"></FCK:editor>
</body>
</html>
<%@ taglib uri=" http://java.fckeditor.net" prefix="FCK" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>fck</title>
</head>
<body>
<FCK:editor instanceName="myEditor" basePath="/fckeditor"></FCK:editor>
</body>
</html>
三、FCKEditor在Java Web项目中的应用。