1. 下载
Zip包:FCKeditor_2.6.4.zip,fckeditor-java-2.4.1-bin.zip,fckeditor-java-2.4.1-src.zip
2. 安装使用
l 将FCKeditor_2.6.4.zip的解压文件放入project的webroot/
l Index.jsp的<head></head>中写入<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
l js引用方法(三种)
M1. form表单中直接引用
<script type="text/javascript">
var oFCKeditor = new FCKeditor('FCKeditor1');
oFCKeditor.BasePath = "/fckeditor/"; //注意修改路径
oFCKeditor.Create();
</script>
M2. 替换表单中的textarea元素
Head中写function()
<script type="text/javascript">
window.onload = function()
{
var oFCKeditor = new FCKeditor( 'MyTextarea' );
oFCKeditor.BasePath = "/fckeditor/";
oFCKeditor.ReplaceTextarea();
}
</script>
Body中加入textarea
<textarea id="MyTextarea" name="MyTextarea">This is the initial value.</textarea>
M3. ajax动态生成
var div = document.getElementById("myFCKeditor");
var fck = new FCKeditor("myFCKeditor");
div.innerHTML = fck.CreateHtml();
3. 取值
M1. String FCKcontent = request.getParameter(“FCKeditor1”);
4. Sample code
Style1.
<html>
<head>
<title>FCKeditor - Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="robots" content="noindex, nofollow">
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
</head>
<body>
<form>
<script type="text/javascript">
var oFCKeditor = new FCKeditor('FCKeditor1');
oFCKeditor.BasePath = "/fckeditor/";
oFCKeditor.Create();
</script>
</form>
</body>
</html>
Style2.
<html>
<head>
<title>FCKeditor - Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="robots" content="noindex, nofollow">
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
<script type="text/javascript">
window.onload = function()
{
var oFCKeditor = new FCKeditor( 'MyTextarea' ) ;
oFCKeditor.BasePath = "/fckeditor/" ;
oFCKeditor.ReplaceTextarea() ;
}
</script>
</head>
<body>
<textarea id="MyTextarea" name="MyTextarea">This is <b>the</b> initial value.</textarea>
</body>
</html>