fckeditor结合ext

首先百度一下fckeditor,如果你要用的话,你找找就可以官网下载,

):

接下来如果想在页面通过标签嵌入方式显示效果的话
必须添加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);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值