Fckeditor是一种大家常用的编辑器,但是他不能像网页表单那样利用document.getelementbyid能获取得到值了,它必须通过 FCKeditorAPI来操作,下面看看Fckeditor内容长度测试
先我们看最简单的就是编辑器的代码了,简单得很同时大家也经常看过。
再看实例,这里限制了fckeditor编辑器内容的长度哦,
window.onload=function(){
function FCKeditor_OnComplete()
{
var editor = FCKeditorAPI.GetInstance('info') ;
editor.Events.AttachEvent('OnSelectionChange', editor_keydown);
}
function editor_keydown(editor)
{
var maxLength=3; //最大输入字数
content= $(editor.EditorDocument.body).text();
var len= content.length;
var $info =$('#info');//存放提示信息
if(len.text("还可以输入 "+(maxLength-len)+"字");
}
if(len == maxLength){
$info.text("字数达到上限");
}
if(len > maxLength){
$info.text(" 输入字符超过"+maxLength+"个,请更改!");
}
}
FCKeditor_OnComplete()
}
复制代码 代码如下:
再看实例,这里限制了fckeditor编辑器内容的长度哦,
复制代码 代码如下:
window.onload=function(){
function FCKeditor_OnComplete()
{
var editor = FCKeditorAPI.GetInstance('info') ;
editor.Events.AttachEvent('OnSelectionChange', editor_keydown);
}
function editor_keydown(editor)
{
var maxLength=3; //最大输入字数
content= $(editor.EditorDocument.body).text();
var len= content.length;
var $info =$('#info');//存放提示信息
if(len
}
if(len == maxLength){
$info.text("字数达到上限");
}
if(len > maxLength){
$info.text(" 输入字符超过"+maxLength+"个,请更改!");
}
}
FCKeditor_OnComplete()
}
以上就是Fckeditor编辑器内容长度限制统计实现方法的详细内容,更多请关注0133技术站其它相关文章!