兩畝三分地

            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            17 隨筆 :: 20 文章 :: 2 評(píng)論 :: 0 Trackbacks
          為了讓博文編輯更方便,這里介紹一下FCKeditor這個(gè)組件, 在這個(gè)項(xiàng)目里我們主要利用這個(gè)組件的工具欄
           

          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í)例
          <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的對(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)注意。

          posted on 2009-09-29 17:16 Chucky 閱讀(112) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 天峨县| 军事| 五家渠市| 庄浪县| 当阳市| 清丰县| 册亨县| 临江市| 安溪县| 大新县| 广安市| 佛坪县| 竹北市| 容城县| 屏东县| 南岸区| 济阳县| 四子王旗| 右玉县| 南开区| 麟游县| 红安县| 博野县| 邵阳市| 嵊州市| 乌鲁木齐县| 敖汉旗| 赤水市| 镶黄旗| 东方市| 奎屯市| 绥中县| 象州县| 麟游县| 嘉义市| 青铜峡市| 台安县| 成安县| 台东市| 富锦市| 新邵县|