fck 添加字数统计

 <div id="textCount"></div>
    <script type="text/javascript">
  window.onload=function(){
    var editors=FCKeditorAPI.GetInstance('body');
     editors.Events.AttachEvent('OnSelectionChange', editor_keydown);
     function editor_keydown(editors){
          var maxLength=420; //最大输入字数
        content= $(editors.EditorDocument.body).text();
     var len= content.length;
        if(len>420){
            alert('你已经输入的次数超过420了');return;
        }
    var sheng=maxLength-len;   
        $('#textCount').html("你还可以输入<span style='color:red;'>"+sheng+"</span>个字");
     }
    //alert(editors);
}

  </script>

你可能感兴趣的:(FCK)