當幸福來敲門

          我就會牢牢抓住!
          隨筆 - 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 閱讀(189) 評論(0)  編輯  收藏


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


          網站導航:
           
          主站蜘蛛池模板: 喀喇沁旗| 平阳县| 抚顺县| 云浮市| 江陵县| 高台县| 蚌埠市| 开封县| 东源县| 宁德市| 微山县| 蓬安县| 蒙自县| 萨迦县| 安康市| 汉阴县| 蒲城县| 千阳县| 青海省| 察隅县| 海盐县| 和林格尔县| 淮安市| 天祝| 常宁市| 大庆市| 察雅县| 伊川县| 泊头市| 老河口市| 绥滨县| 常德市| 泽州县| 德庆县| 峨山| 积石山| 河曲县| 梅河口市| 开封县| 沈丘县| 广宁县|