Fckeditor用法

试Fckeditor版本号:2.6.3

眼下Fckeditor仅仅能用于基于ie内核的浏览器,假设要使用于chrome等浏览器,请使用ckeditor。


详细用法:

1.将解压后的fckeditor整个目录拷贝到ProjectWebRoot路径下

2.在要使用Fckeditor的页面,导入fckeditor.js(在fckeditor目录里)文件

由于此处使用Fckeditor用到了jQuery,因此对应的jquery.js也要导入

<script language="javascript" src="${pageContext.request.contextPath}/script/jquery.js"></script>
<script language="javascript" src="${pageContext.request.contextPath}/fckeditor/fckeditor.js" charset="utf-8"></script>

3.依据须要适当改动下面JS代码,拷贝到要使用Fckeditor的页面就可以

<script type="text/javascript">
		$(function(){
			var fck = new FCKeditor("content");//content为要替换的textarea的name属性
			fck.Width = "99%";
			fck.Height = "100%";
			fck.ToolbarSet = "bbs";//指定工具栏的配置。bbs为我自己改动过的,假设不使用自己定义配置文件,此处有Default,Basic两个选择
			fck.BasePath = "${pageContext.request.contextPath}/fckeditor/";
			fck.ReplaceTextarea();
		});
</script>

替换成Fckeditor的textarea,名字和上面的替换的名字要一致。

<textarea name="content" style="650px;height:200px"></textarea>

PS:代码解释

JS代码中各个參数详细作用(使用本js或者上文用法步骤3的代码都能够,两段代码大同小异)

<script type="text/javascript">

		var oFCKeditor = new FCKeditor( 'content' ) ;//此參数会作为提交表单时的參数名
		oFCKeditor.BasePath	= "/fckeditor/" ;//一定要指定editor目录所在的路径,而且要以'/'结尾
		oFCKeditor.Height	= 300 ;//高度
		oFCKeditor.Value	= '' ;//默认的初始值
		oFCKeditor.ToolbarSet="Basic";//指定工具栏的配置,默觉得Default
		//oFCKeditor.Create() ;//在当前位置生成并显示Fckeditor
		oFCKeditor.ReplaceTextarea();//替换指定id或name属性的textarea为Fckeditor
</script>

使用自己定义的配置文件

1.在fckconfig.js里将FCKConfig.CustomConfigurationsPath = ''改动为:  FCKConfig.CustomConfigurationsPath = FCKConfig.EditorPath + "myconfig.js"  作用:告诉Fckeditor,我有个自己定义的配置在该地址下的该文件。

2.在myconfig.js里写想改动的东西,比如:表情。Fckeditor菜单条的降低等,模版在fckconfig.js里面有。參考着改动就可以。没有改动的配置。Fckeditor默认配置使用自己的默认。


版权声明:本文博主原创文章,博客,未经同意不得转载。

原文地址:https://www.cnblogs.com/mengfanrong/p/4799145.html