fckeditor_for_java的用法

在不少時候都須要使用網頁編輯器,包括在文章發佈的時候或是在表單設計的時候。下面爲fckeditor的使用。
 
以javascript方法調用
 方法(一)
 將fckeditor.jar包拷貝到webroot目錄下,新建一html文件,加如一下代碼
 拷代碼(在head內):
 <script type="text/javascript" src="fckeditor/fckeditor.js"></script>
 在body內:
 <script type="text/javascript">
    var oFCKeditor = new FCKeditor('FCKeditor');
    // http://localhost:8080/fckeditor
    // http://localhost:8080/test/fckeditor
    oFCKeditor.BasePath = "test/fckeditor/"; // test/是基路徑,注意Basepath必定要以斜線結尾
    
     oFCKeditor.Width = "60";  //指定fckeditor的寬度
     oFCKeditor.Height = "400"; //指定fckeditor的高度
     oFCKeditor.Value = "initial value"; //指定fckeditor的初始值
     oFCKeditor.ToolBarSet = "Basic"; //指定fckeditor的工具集類型
     
    oFCKeditor.Create();
 </script>
 
 方法(二)
 將fckeditor.jar包拷貝到webroot目錄下,新建一html文件
   拷代碼(在head內):
      <script type="text/javascript" src="fckeditor/fckeditor.js"></script> //src中第一個fckeditor是項目名稱
      <script type="text/javascript">
        window.onload = function(){
            var oFCKeditor = new FCKeditor('MyTextarea');
            oFCKeditor.BasePath = "fckeditor/";
            oFCKeditor.ReplaceTextarea();
          }
      </script>
     在body內加代碼:
        <TEXTAREA row="4" cols="60" name="MyTextarea">this is value</TEXTAREA> 
        
 *********************************       
 在jsp中經過自定義標籤調用:
   能夠參考:(根據最新版原本定)  
     1,演示工程fckeditor-java-demo-2.4.war
           不能直接查看已經發布後訪問到的頁面的源碼,由於那是個jsp頁面,看項目自己的js文檔
     2,fckeditor-java-2.4的文檔(解壓fckeditor-java-bin.rar)
           1)新建jsp頁面
           2)拷jar包:fckeditor-java-core.jar(核心jar包),lib下的兩個文件上傳的和日誌的jar包
           3)寫代碼:
                <%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>
              在body內:
                 <FCK:editor instanceName="myEditor" basePath="/fckeditor" value="this is my content"></FCK:editor> 
              //basepath必定要以'/'開頭,  '/'表明當前工程的路徑
              //必定要設置value屬性的值,而且值不能是空字符串 
            注:可能會出現缺乏類的狀況,比較方便的方法是看已提供的demo項目!!     
            
   *****************************
   配置文件(自定義配置):
      1,在fckeditor中有一個fckconfig.js文件,而後能夠直接進行相應的修改,通常不採用這種方法,而是採用額外的文件
      2,在webroot下見一個myconfig.js文件,只需寫須要修改的配置項(參考文檔)
          FCKConfig.AutoDetectLanguage = false ;
       3,
          1>在fckeditor中自帶的fckconfig.js文件中指定
             FCKConfig.CustomConfigurationsPath = '/test/myconfig.js';
          2>在頁面代碼中調用代碼對FCKeditor的實例進行配置:
             body中的fckeditor中指定: oFCKeditor.Config["CustomConfigurationPath"] = '/test/myconfig.js';
       4,從新部署便可
 
以上爲fckeditor的使用步驟,同時也能夠用java代碼的方式寫成標籤。
相關文章
相關標籤/搜索