---
title: "FCKeditor - JS操作FCKeditor"
author: "topsale"
date: "2011-04-12T12:13:40Z"
tags: ["HTML", "fckeditor"]
categories: ["Web前端"]
slug: "fckeditor-js-fckeditor"
draft: false
lastmod: "2011-04-12T12:15:36Z"
id: 998743
url: "https://topsale.iteye.com/blog/998743"
---

东西不多，却必须要用到。

代码如下：

```js

//获取编辑器中HTML内容 
function getEditorHTMLContents(EditorName) { 
	var oEditor = FCKeditorAPI.GetInstance(EditorName); 
	return(oEditor.GetXHTML(true)); 
}

//获取编辑器中文字内容 
function getEditorTextContents(EditorName) { 
	var oEditor = FCKeditorAPI.GetInstance(EditorName); 
	return(oEditor.EditorDocument.body.innerText); 
}

//设置编辑器中内容 
function SetEditorContents(EditorName, ContentStr) { 
	var oEditor = FCKeditorAPI.GetInstance(EditorName) ; 
	oEditor.SetHTML(ContentStr) ; 
}

```