---
title: "在线编辑器 ckeditor3.x的配置使用"
author: "fancy205"
date: "2009-12-16T10:00:22Z"
tags: []
categories: ["Web前端"]
slug: "ckeditor3-x"
draft: false
lastmod: "2009-12-16T10:02:27Z"
id: 549432
url: "https://fancy205.iteye.com/blog/549432"
---

好吧，首先祝贺自己在javaeye安家。 :) 
     进入正题，由于工作的需要。就在网上找了些在线编辑器，诸如：eWebEditor，FCKeditor，CKeditor等。FCKeditor与CKeditor是一样的，只不过在3.0之后更改了名字，FCKeditor2.x的配置相对于3.x来说，比较麻烦。
     **1.FCKeditor配置使用**
     首先把fckeditor文件夹放到你的web站点根目录下，在你需要使用的页面导入FCKeditor
     <script type="text/javascript" src="fckeditor/fckeditor.js"></script>
     创建FCKeditor通常有几种方法：
      第一种：嵌入式引用
      在你需要的地方增加一下代码段
    
```java
<script type="text/javascript">
			var oFCKeditor = new FCKeditor("FCKeditor1");
			oFCKeditor.BasePath = "/reg/fckeditor/";
			oFCKeditor.Create();
		
		</script>
```

    例如

```java
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE>inline </TITLE>
 
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>

 </HEAD>

 <BODY>
  	<form>
		<script type="text/javascript">
			var oFCKeditor = new FCKeditor("FCKeditor1");
			oFCKeditor.BasePath = "/reg/fckeditor/";
			oFCKeditor.Create();
		
		</script>
	
	</form>
 </BODY>
</HTML>

```

   第二种：替换textarea
   
```java
<script type="text/javascript">
		window.onload = function(){
			var oFCKeditor = new FCKeditor("exarea");
			oFCKeditor.BasePath = "/reg/fckeditor/";
			oFCKeditor.ReplaceTextarea();
		}
		</script>
		<textarea id="exarea" name="exarea"></textarea>
```


    上面是对FCKeditor配置使用的介绍，即是ckeditor3.0以前的版本。

    **2.ckeditor的配置使用**
    相对FCKeditor来说，ckeditor 3.x的安装使用是简单了很多，只需一下简单的几步操作就ok了：
     a、下载最新的ckeditor <http://ckeditor.com/download>
    b、抽取出editor文件夹放到你所属站点的根目录
     c、在需要使用编辑器的地方引入
```java
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
```

    加入一下代码就可以了
    
```java
 <textarea class="ckeditor" cols="80" id="editor" name="editor" rows="10">
                这里是内容
    </textarea>
```

     c、部署好后，还可以查看ckeditor自带的例子

```java
http://你的站点地址<CKEditor installation path>/_samples/index.html

```