當幸福來敲門

          我就會牢牢抓住!
          隨筆 - 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)  編輯  收藏


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


          網站導航:
           
          主站蜘蛛池模板: 措勤县| 嵩明县| 德格县| 左云县| 鄂温| 新巴尔虎右旗| 常州市| 岳阳县| 大悟县| 嘉祥县| 浦江县| 潍坊市| 辽阳市| 铜鼓县| 乌兰察布市| 鲁山县| 双鸭山市| 漳平市| 鹿泉市| 璧山县| 瑞昌市| 贵德县| 濮阳市| 方山县| 深圳市| 土默特右旗| 于田县| 建昌县| 黄梅县| 长白| 望城县| 安岳县| 台南县| 临汾市| 揭西县| 韩城市| 麟游县| 永善县| 平南县| 泗水县| 连城县|