FCKeditor Editor content length Limit Statistics Implementation Method _ Web page Editor

Source: Internet
Author: User
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 ()
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.