---
title: "FCKeditor应用笔记"
author: "guodongbingtuan"
date: "2009-05-12T18:07:00Z"
tags: []
slug: "fckeditor"
draft: false
lastmod: "2009-05-12T18:07:00Z"
id: 420970
url: "https://javaroad.iteye.com/blog/420970"
---

&lt;script&gt;function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}&lt;/script&gt;

1． 下载

官网：[www.fckeditor.net](http://www.fckeditor.net/)

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的&lt;head&gt;&lt;/head&gt;中写入&lt;script type="text/javascript" src="fckeditor/fckeditor.js"&gt;&lt;/script&gt;

l js引用方法(三种)

**M1.** form表单中直接引用

&lt;script type="text/javascript"&gt;

var oFCKeditor = new FCKeditor('FCKeditor1');

oFCKeditor.BasePath = "/fckeditor/"; //注意修改路径

oFCKeditor.Create();

&lt;/script&gt;

**M2.** 替换表单中的textarea元素

Head中写function()

&lt;script type="text/javascript"&gt;

window.onload = function()

{

var oFCKeditor = new FCKeditor( 'MyTextarea' );

oFCKeditor.BasePath = "/fckeditor/";

oFCKeditor.ReplaceTextarea();

}

&lt;/script&gt;

Body中加入textarea

&lt;textarea id="MyTextarea" name="MyTextarea"&gt;This is the initial value.&lt;/textarea&gt;

**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.**

&lt;html&gt;

&lt;head&gt;

&lt;title&gt;FCKeditor - Sample&lt;/title&gt;

&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;

&lt;meta name="robots" content="noindex, nofollow"&gt;

&lt;script type="text/javascript" src="fckeditor/fckeditor.js"&gt;&lt;/script&gt;

&lt;/head&gt;

&lt;body&gt;

&lt;form&gt;

&lt;script type="text/javascript"&gt;

var oFCKeditor = new FCKeditor('FCKeditor1');

oFCKeditor.BasePath = "/fckeditor/";

oFCKeditor.Create();

&lt;/script&gt;

&lt;/form&gt;

&lt;/body&gt;

&lt;/html&gt;

**Style2.**

&lt;html&gt;

&lt;head&gt;

&lt;title&gt;FCKeditor - Sample&lt;/title&gt;

&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;

&lt;meta name="robots" content="noindex, nofollow"&gt;

&lt;script type="text/javascript" src="fckeditor/fckeditor.js"&gt;&lt;/script&gt;

&lt;script type="text/javascript"&gt;

window.onload = function()

{

var oFCKeditor = new FCKeditor( 'MyTextarea' ) ;

oFCKeditor.BasePath = "/fckeditor/" ;

oFCKeditor.ReplaceTextarea() ;

}

&lt;/script&gt;

&lt;/head&gt;

&lt;body&gt;

&lt;textarea id="MyTextarea" name="MyTextarea"&gt;This is &lt;b&gt;the&lt;/b&gt; initial value.&lt;/textarea&gt;

&lt;/body&gt;

&lt;/html&gt;