首先百度一下fckeditor,如果你要用的话,你找找就可以官网下载,
):
接下来如果想在页面通过标签嵌入方式显示效果的话
必须添加java-core2.4.jar包来获取FCK的相应标签
1. 标签方式话代码如下
要使用标签就要先导入fck的便签库
2.JavaScript方式的话不需导入标签库
在head标签首先要导入已经写好的fckeditor.js文件
我在这里写下最最常用的两个方法,就是 代码读写 fckeditor的内容:
下面是我[b]结合ext[/b]写的js文件的代码:
):
接下来如果想在页面通过标签嵌入方式显示效果的话
必须添加java-core2.4.jar包来获取FCK的相应标签
1. 标签方式话代码如下
要使用标签就要先导入fck的便签库
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
<FCK:editor instanceName="content" value=" " width="85%" height="300px">
<FCK:config SkinPath="skins/silver/" AutoDetectLanguage="true" />
</FCK:editor>
2.JavaScript方式的话不需导入标签库
在head标签首先要导入已经写好的fckeditor.js文件
<script type="text/javascript" src="${ctx}/fckeditor/fckeditor.js"></script>
<script type="text/javascript">
window.onload(function(){
var oFCKeditor=new FCKeditor('MyTextarea');
oFCKeditor.BasePath=[b]项目webRoot[/b]+"fckeditor/"; //这个路径很重要。 很多人js导入都是因为这个路径没有写好。
oFCKeditor.ReplaceTextarea();
});
</script>
<textarea rows="4" cols="60" name="MyTextarea"></textarea>
我在这里写下最最常用的两个方法,就是 代码读写 fckeditor的内容:
下面是我[b]结合ext[/b]写的js文件的代码:
/**
*
*/
Ext.onReady(function(){
var panel=new Ext.form.FormPanel({
text:'fckeditor',
renderTo:document.body,
id:'fck',
items:[{
xtype : "textarea",
name : "content",
anchor : '97%',
height : 400,
id : "content",
// fieldLabel : "内容",
listeners : {
"render" : function(f) {
fckEditor = new FCKeditor("content");
// fckEditor.Height = 400;
// fckEditor.Width = 530;
fckEditor.BasePath = ctx+"/fckeditor/";
fckEditor.ReplaceTextarea();
}
}
},{
xtype:'button',text:'取出',handler:function(){
alert(getEditorContents("content"));
}
},{
xtype:'textfield',name:'text',id:'text',fieldLabel:'请输入'
},{
xtype:'button',text:'输进',handler:function(){
SetContents(Ext.getCmp('text').getValue(),[b]'content'[/b]);
}
}]
})
}
);
//写
//参数:0:内容 1:fckeditor的id
function SetContents(codeStr,content){
var oEditor = FCKeditorAPI.GetInstance(content) ;
oEditor.SetHTML(codeStr) ;
}
//读
//参数 0:fckeditor的id
function getEditorContents(content){
var oEditor = FCKeditorAPI.GetInstance(content);
return oEditor.GetXHTML(false);
}