两亩三分地

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  17 随笔 :: 20 文章 :: 2 评论 :: 0 Trackbacks
为了让博文编辑更方便,这里介绍一下FCKeditor这个组件, 在这个项目里我们主要利用这个组件的工具栏
 

FCKeditor提供了很详细的文档,关于FCKeditor的安装,软件本身提供了对多种语言的支持,根据项目的需要,这里着重介绍javascript的安装方法。
首先在网页的表头添加下面的声明
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
接下来有3种不同的方法使用FCKeditor,
方法一. inline方式 在网页body部分,把编辑器放在你想放的地方(通常在表单里面),在该位置添加以下脚本:
<script type="text/javascript">
var oFCKeditor = new FCKeditor('FCKeditor1');
oFCKeditor.BasePath 
= "/fckeditor/";
oFCKeditor.Create();
</script>
方法一实例
<html>
<head>
<title>FCKeditor - Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="robots" content="noindex, nofollow">
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
</head>
<body>
<form>
<script type="text/javascript">
var oFCKeditor = new FCKeditor('FCKeditor1');
oFCKeditor.BasePath 
= "/fckeditor/";
oFCKeditor.Create();
</script>
</form>
</body>
</html>

方法二 替换TextArea方式
1.先在Head部位添加onload方法
<script type="text/javascript">
window.onload 
= function()
{
var oFCKeditor = new FCKeditor( 'MyTextarea' ) ;
oFCKeditor.BasePath 
= "/fckeditor/" ;
oFCKeditor.ReplaceTextarea() ;
}
</script>
2.在<body>部分 添加并替换原先的TextArea
<textarea id="MyTextarea" name="MyTextarea">This is <b>the</b> initial value.</textarea>
注意 textarea的名字和FCKeditor的对象名称一致

现在我们就可以使用一个很漂亮方便的工具栏了


但是在个漂亮的工具栏Font里面是没有宋体,黑体之类的中文字体的,所以在使用前,我们还要做一定的修改。
打开fckeditor/fckconfig.js,找到并修改FCKConfig.FontNames如下
FCKConfig.FontNames        = '宋体;黑体;隶书;楷体_GB2312;幼圆;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;

好了经过安装FCKeditor这个编辑器基本就可以使用了。
值得注意的是,FCKeditor的属性是case sensitive,所以在使用的时候千万注意。

posted on 2009-09-29 17:16 Chucky 阅读(104) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: