Head:
<script type="text/javascript" src="editor_path/fckeditor.js"></script>
Html:
<textarea id="content" name="content" style=" 100%"></textarea>
Javascript:
var oFCKeditor = new FCKeditor('content'); // content为textarea的id
oFCKeditor.BasePath = "../FCKeditor/"; // editor跟路径
oFCKeditor.Height = "100%"; // 高度度设置
oFCKeditor.Width = "100%"; // 宽度度度设置
oFCKeditor.ToolbarSet = "None"; // 工具条设置
oFCKeditor.Config["ToolbarStartExpanded"] = false; // 属性配置
oFCKeditor.ReplaceTextarea();
<script type="text/javascript" src="editor_path/fckeditor.js"></script>
Html:
<textarea id="content" name="content" style=" 100%"></textarea>
Javascript:
var oFCKeditor = new FCKeditor('content'); // content为textarea的id
oFCKeditor.BasePath = "../FCKeditor/"; // editor跟路径
oFCKeditor.Height = "100%"; // 高度度设置
oFCKeditor.Width = "100%"; // 宽度度度设置
oFCKeditor.ToolbarSet = "None"; // 工具条设置
oFCKeditor.Config["ToolbarStartExpanded"] = false; // 属性配置
oFCKeditor.ReplaceTextarea();
2. 操作编辑器
取得对象:
var oEditor = FCKeditorAPI.GetInstance('content ');
取得名字:
var editorName = oEditor.Name;
取得内容:
var content = oEditor.GetXHTML(true);
设置内容:
oEditor.SetHTML(‘html’);
插入内容到当前光标处:
oEditor.InsertHtml(‘html’);
更新内容到textarea:
oEditor.UpdateLinkedField();
var oEditor = FCKeditorAPI.GetInstance('content ');
取得名字:
var editorName = oEditor.Name;
取得内容:
var content = oEditor.GetXHTML(true);
设置内容:
oEditor.SetHTML(‘html’);
插入内容到当前光标处:
oEditor.InsertHtml(‘html’);
更新内容到textarea:
oEditor.UpdateLinkedField();
要点:
Fckeditor所有方法和属性的第一个单词的首字母都是大写
3. 有用事件
编辑器加载完毕后会自动调用名字为FCKeditor_OnComplete的函数,并将自身作为参数传递进去,一般在FCKeditor_OnComplete函数初始化编辑器
function FCKeditor_OnComplete(editorInstance)
{
// init code
alert(editorInstance.Name) ;
}
{
// init code
alert(editorInstance.Name) ;
}