富文本編輯器kindeditor配置

<!--富文本編輯器kindeditor配置↓ -->
<link type="text/css" rel="stylesheet" href="kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="kindeditor/plugins/code/prettify.css" />
<script type="text/javascript" charset="utf-8" src="kindeditor/kindeditor-min.js"></script>
<script type="text/javascript" charset="utf-8" src="kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript" charset="utf-8" src="kindeditor/plugins/code/prettify.js"></script>
<script type="text/javascript">
    KindEditor.ready(function (K) {
        var editor1 = K.create('#content1', {
            items: [
'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
'removeformat', 'strikethrough', 'lineheight', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
'insertunorderedlist', '|', 'emoticons', 'link', 'insertfile', 'media', '|', 'image', 'multiimage', 'map', 'baidumap', '|', 'preview', 'fullscreen',
],
            cssPath: 'kindeditor/plugins/code/prettify.css',
            uploadJson: 'kindeditor/asp.net/upload_json.ashx',
            fileManagerJson: 'kindeditor/asp.net/file_manager_json.ashx',
            allowFileManager: true,
               afterChange : function() {
      $('.word_count1').html(this.count()); //字數統計包含HTML代碼
      $('.word_count2').html(this.count('text'));  //字數統計包含純文本、IMG、EMBED,不包含換行符,IMG和EMBED算一個文字
      //////////
      //限制字數
      var limitNum = 40000;  //設定限制字數
      var pattern = '還能夠輸入' + limitNum + '字';
      $('.word_surplus').html(pattern); //輸入顯示
      if(this.count('text') > limitNum) {
       pattern = ('字數超過限制,請適當刪除部份內容');
       //超過字數限制自動截取
       var strValue = editor.text();
       strValue = strValue.substring(0,limitNum);
       editor.text(strValue);      
       } else {
       //計算剩餘字數
       var result = limitNum - this.count('text');
       pattern = '還能夠輸入' +  result + '字';
       }
       $('.word_surplus').html(pattern); //輸入顯示
      ////////
     } ,



            pasteType: 1,
            afterCreate: function () {
                var self = this;
                K.ctrl(document, 13, function () {
                    self.sync();
                    K('form[name=form1]')[0].submit();
                });
                K.ctrl(self.edit.doc, 13, function () {
                    self.sync();
                    K('form[name=form1]')[0].submit();
                });
            }
        });
        prettyPrint();
    });
</script>
<!--富文本編輯器kindeditor配置↑--> 
View Code
            <dt><span class="red">*</span> 職位描述:</dt>
            <dd >
            您當前輸入了 <span class="word_count1">0</span> 個文字。(字數統計包含HTML代碼。)<span class="word_surplus"></span>    
              
            </dd>
            <dd >              
           <textarea id="content1" name="content1" style="width:700px;height:300px;visibility:hidden;"></textarea>
                                    
            </dd>
View Code

相關文章
相關標籤/搜索