首页前端开发其他前端知识Fckeditor编辑器内容长度限制统计实现方法

Fckeditor编辑器内容长度限制统计实现方法

时间2024-02-10 11:42:03发布访客分类其他前端知识浏览786
导读:收集整理的这篇文章主要介绍了Fckeditor编辑器内容长度限制统计实现方法,觉得挺不错的,现在分享给大家,也给大家做个参考。 先我们看最简单的就是编辑器的代码了,简单得很同时大家也经常...
收集整理的这篇文章主要介绍了Fckeditor编辑器内容长度限制统计实现方法,觉得挺不错的,现在分享给大家,也给大家做个参考。 先我们看最简单的就是编辑器的代码了,简单得很同时大家也经常看过。
复制代码 代码如下:
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 = '没有最好,只有更好,大家努力' ;
oFCKeditor.Height = 450 ;
oFCKeditor.Width = 660 ;
oFCKeditor.Create() ;
//-->
/script>
input type="button" value="检测字数(包括HTML代码)" style="width:165px; " class="inputc" onClick="checklength()">
script>

//检测在线编器字符数 ,他必须通过创建FCKeditorAPI来实现,代码如下。
复制代码 代码如下:
function checklength()
{
var Content;
var oEditor = FCKeditorAPI.GetInstance('Content') ;
Content=oEditor.GetXHTML(true)
alert("n当前: "+Content.length+" 个字符");
return false;
}
/script>

再看实例,这里限制了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 maxLength){
.text("还可以输入 "+(maxLength-len)+"字");
}
if(len == maxLength){
$info.text("字数达到上限");
}
if(len > maxLength){
$info.text(" 输入字符超过"+maxLength+"个,请更改!");
}
}
FCKeditor_OnComplete()
}
您可能感兴趣的文章:
  • FCKEditor超级链接默认新窗口打开的修改方法
  • Smarty中调用FCKeditor的方法
  • fckeditor编辑器下的自定义分页符实现方法
  • FCKeditor编辑器添加图片上传功能及图片路径问题解决方法
  • ThinkPHP中FCKeditor编辑器的使用方法
  • fckeditor编辑器在php中的配置方法
  • FCKeditor 图片上传进度条不动的解决方法
  • php在页面中调用fckeditor编辑器的方法
  • 浏览器执行history.go(-1) FCKeditor编辑框内显示html源代码的解决方法
  • FCK编辑器(FCKEditor)添加新按钮和功能的修改方法
  • fckeditor粘贴Word时弹出窗口取消的方法

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: Fckeditor编辑器内容长度限制统计实现方法
本文地址: https://pptw.com/jishu/608313.html
KindEditor 4.x 在线编辑器常用方法小结 PHP中CKEditor和CKFinder配置问题小结

游客 回复需填写必要信息