欢迎来到代码驿站!

当前位置:首页 >

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

时间:2021-05-07 10:49:59|栏目:|点击:
先我们看最简单的就是编辑器的代码了,简单得很同时大家也经常看过。
复制代码 代码如下:

<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()
}

上一篇:易语言调节器限制最大值和最小值的方法

栏    目:

下一篇:docker 容器上编译 go 程序提示找不到文件问题

本文标题:Fckeditor编辑器内容长度限制统计实现方法

本文地址:http://www.codeinn.net/misctech/116677.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有