為了讓博文編輯更方便,這里介紹一下FCKeditor這個(gè)組件,
在這個(gè)項(xiàng)目里我們主要利用這個(gè)組件的工具欄

FCKeditor提供了很詳細(xì)的文檔,關(guān)于FCKeditor的安裝,軟件本身提供了對(duì)多種語(yǔ)言的支持,根據(jù)項(xiàng)目的需要,這里著重介紹javascript的安裝方法。
首先在網(wǎng)頁(yè)的表頭添加下面的聲明
方法一. inline方式 在網(wǎng)頁(yè)body部分,把編輯器放在你想放的地方(通常在表單里面),在該位置添加以下腳本:
方法二 替換TextArea方式
1.先在Head部位添加onload方法
現(xiàn)在我們就可以使用一個(gè)很漂亮方便的工具欄了

但是在個(gè)漂亮的工具欄Font里面是沒(méi)有宋體,黑體之類的中文字體的,所以在使用前,我們還要做一定的修改。
打開(kāi)fckeditor/fckconfig.js,找到并修改FCKConfig.FontNames如下
好了經(jīng)過(guò)安裝FCKeditor這個(gè)編輯器基本就可以使用了。
值得注意的是,F(xiàn)CKeditor的屬性是case sensitive,所以在使用的時(shí)候千萬(wàn)注意。

FCKeditor提供了很詳細(xì)的文檔,關(guān)于FCKeditor的安裝,軟件本身提供了對(duì)多種語(yǔ)言的支持,根據(jù)項(xiàng)目的需要,這里著重介紹javascript的安裝方法。
首先在網(wǎng)頁(yè)的表頭添加下面的聲明
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
接下來(lái)有3種不同的方法使用FCKeditor,方法一. inline方式 在網(wǎng)頁(yè)body部分,把編輯器放在你想放的地方(通常在表單里面),在該位置添加以下腳本:
<script type="text/javascript">
var oFCKeditor = new FCKeditor('FCKeditor1');
oFCKeditor.BasePath = "/fckeditor/";
oFCKeditor.Create();
</script>
方法一實(shí)例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>
<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>部分 添加并替換原先的TextAreawindow.onload = function()
{
var oFCKeditor = new FCKeditor( 'MyTextarea' ) ;
oFCKeditor.BasePath = "/fckeditor/" ;
oFCKeditor.ReplaceTextarea() ;
}
</script>
<textarea id="MyTextarea" name="MyTextarea">This is <b>the</b> initial value.</textarea>
注意 textarea的名字和FCKeditor的對(duì)象名稱一致現(xiàn)在我們就可以使用一個(gè)很漂亮方便的工具欄了

但是在個(gè)漂亮的工具欄Font里面是沒(méi)有宋體,黑體之類的中文字體的,所以在使用前,我們還要做一定的修改。
打開(kāi)fckeditor/fckconfig.js,找到并修改FCKConfig.FontNames如下
FCKConfig.FontNames = '宋體;黑體;隸書(shū);楷體_GB2312;幼圓;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;
好了經(jīng)過(guò)安裝FCKeditor這個(gè)編輯器基本就可以使用了。
值得注意的是,F(xiàn)CKeditor的屬性是case sensitive,所以在使用的時(shí)候千萬(wàn)注意。