First of all we see the simplest is the editor code, very simple at the same time we often read.
Copy Code code as follows:
<script type= "Text/javascript" src= "/editor/fckeditor.js" ></script>
<script type= "Text/javascript" >
<!--
var ofckeditor = new FCKeditor (' Content ');
Ofckeditor.basepath = "/editor/";
Ofckeditor.toolbarset = "User";
Ofckeditor.value = ' No best, only better, everybody effort ';
Ofckeditor.height = 450;
Ofckeditor.width = 660;
Ofckeditor.create ();
-->
</script>
<input type= "button" value= "detect words (including HTML code)" style= "width:165px" class= "INPUTC" onclick= "Checklength" () ">
<script>
To detect the number of online encoder characters, he must create FCKEDITORAPI to implement the code as follows.
Copy Code code as follows:
function Checklength ()
{
var Content;
var oeditor = fckeditorapi.getinstance (' Content ');
Content=oeditor.getxhtml (True)
Alert ("N Current:" +content.length+ "character");
return false;
}
</script>
Looking at the example again, this limits the length of the FCKeditor Editor's content.
Copy Code code as follows:
Window.onload=function () {
function fckeditor_oncomplete ()
{
var editor = fckeditorapi.getinstance (' info ');
Editor. Events.attachevent (' Onselectionchange ', editor_keydown);
}
Function Editor_keydown (editor)
{
var maxlength=3;//MAX input word
content= $ editor. editordocument.body). text ();
var len= content.length;
var $info =$ (' #info ');//Store prompt information
if (Len < maxLength) {
. Text ("also can enter" + (Maxlength-len) + "word");
}
if (len = = maxLength) {
$info. Text ("Maximum words reached");
}
if (Len > MaxLength) {
$info. Text ("Enter a character more than the +maxlength+", change!) ");
}
}
Fckeditor_oncomplete ()
}