---
title: "fckeditor编辑器的一些用法校验和加载"
author: "ericxu131"
date: "2008-03-21T13:17:49Z"
tags: []
slug: "fckeditor"
draft: false
lastmod: "2008-03-21T13:17:49Z"
id: 174470
url: "https://ericxu131.iteye.com/blog/174470"
---

fckeditor编辑器其实是运行在一个iframe当中，所以常规的校验需要先通过fckeditor的api来进行连接后才能正常的进行操作。代码如下：

```
var oFCKeditor=FCKeditorAPI.GetInstance('content');
oFCKeditor.UpdateLinkedField();
alert(document.form[0].content.value);
```

 

在正常打开页面时如果加载完整的fck编辑器会使页面打开很慢，所以可以一开始通过以下方式变通。代码如下：

```
<TEXTAREA name="content" id="content" style="height=350;width=100%"></TEXTAREA>
```

```
<INPUT type="button" value="打开编辑器" onclick="showFKCEditer(this);">
```

 

```
function showFKCEditer(show_ob)
 {
 var oFCKeditor = new FCKeditor('content') ;
 oFCKeditor.ToolbarSet = "MyBasic";
 oFCKeditor.Config['SkinPath'] = '<%=request.getContextPath()%>/components/fckeditor/' + 'editor/skins/office2003/' ;
 oFCKeditor.BasePath = '<%=request.getContextPath()%>/components/fckeditor/' ;
 oFCKeditor.Height = 350 ;
 //oFCKeditor.Width = '96%';
 oFCKeditor.Value = '' ;
 //oFCKeditor.Create() ; 
 oFCKeditor.ReplaceTextarea() ;
 var cur_tr=findFirstParentTR(show_ob);
 cur_tr.parentElement.removeChild(cur_tr);
 }
```

 

不过在使用fck的api要先引入它的fckeditor/fckeditor.js包![biggrin](../../images/smiles/icon_biggrin.gif "biggrin")