當幸福來敲門

          我就會牢牢抓住!
          隨筆 - 50, 文章 - 3, 評論 - 8, 引用 - 0
          數據加載中……

          FCKeditor 取值

          《轉自http://blog.sina.com.cn/s/blog_5f66526e0100kf6b.html

          主要步驟:

          第一步:導入需要的js文件(根據實際情況修改相應路徑)
          <script src="js/jquery.js" type=text/javascript></script>   
          <script src="fckeditor/fckeditor.js" type="text/javascript"></script>
          第二步:初始化(根據實際情況修改相應路徑)   

          sBasePath    = '/duotunkf/fckeditor/' ;#編輯器所在文件夾;
          oFCKeditor    = new FCKeditor('content') ;
          oFCKeditor.BasePath = sBasePath ;
          oFCKeditor.Value = 'test' ;
          oFCKeditor.ToolbarSet = 'Basic' ;
          oFCKeditor.Create() ;

          其中content為頁面你所綁定的textArea的id或name

          第三步:取值

          var oEditor = FCKeditorAPI.GetInstance('content');  
          editorValue = oEditor.GetHTML();  
          第四步:賦值(更新的時候先把原有的值賦給textarea)

          var oEditor = FCKeditorAPI.GetInstance('content');  
          oEditor.SetHTML("value"); 

           

          下面是本人寫的一個賦值測試程序,供大家參考。源碼如下:

          <html>
           <head>

               <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                  <script src="js/jquery-1.3.2.min.js"></script>
                  <script src="fckeditor/fckeditor.js"></script>
                  <script>
                  $(document).ready(function(){
                    $("#test").click(function(){
              var oEditor = FCKeditorAPI.GetInstance('content');  
              oEditor.SetHTML($("#test option:selected" ).text());
              });
            });
                  </script>
           </head>
           <body>
            
            <form action="" method="post">
                  <script>
                      sBasePath    = '/duotunkf/fckeditor/' ;#編輯器所在文件夾;
                      oFCKeditor   = new FCKeditor('content') ;
                      oFCKeditor.BasePath = sBasePath ;
                      oFCKeditor.Value = 'test' ;
                      oFCKeditor.ToolbarSet = 'Basic' ;
                      oFCKeditor.Create() ;
            </script>
             <br>
                      <label for="test">
                <select name="test" size="4" id="test">
                  <option value="1">i.點擊這里改變編輯器的值</option>
                  <option value="2">ii.點擊這里改變編輯器的值</option>
                  <option value="3">iii.點擊這里改變編輯器的值</option>
                     </select>
                    </label>
            </form>
           </body>
          </html>


          posted on 2013-07-31 14:19 wyx 閱讀(182) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 通辽市| 阿尔山市| 米易县| 安国市| 平舆县| 元谋县| 阿勒泰市| 长沙县| 新干县| 凤阳县| 阿克苏市| 玉树县| 苍南县| 土默特右旗| 南昌县| 榕江县| 牡丹江市| 阿坝县| 承德县| 青田县| 东方市| 金阳县| 西贡区| 北京市| 阿尔山市| 沁阳市| 肥西县| 农安县| 灌南县| 庆元县| 滁州市| 陈巴尔虎旗| 湘乡市| 汝阳县| 舞阳县| 汽车| 梁河县| 闵行区| 福海县| 高安市| 财经|