Fckeditor编辑器内容长度限制统计实现
2012-03-04 19:34
363 查看
先我们看最简单的就是编辑器的代码了,简单得很同时大家也经常看过。
代码如下 复制代码
<script type="text/javascript" src="/editor/fckeditor.js"></script>
<script type="text/javascript">
<!--
var oFCKeditor = new FCKeditor( 'Content' ) ;
oFCKeditor.BasePath = "/ www.hzhuti.com /" ;
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()
}
本站原创文章,转载必须注明来源于http://www.111cn.net/wy/yw.html
代码如下 复制代码
<script type="text/javascript" src="/editor/fckeditor.js"></script>
<script type="text/javascript">
<!--
var oFCKeditor = new FCKeditor( 'Content' ) ;
oFCKeditor.BasePath = "/ www.hzhuti.com /" ;
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()
}
本站原创文章,转载必须注明来源于http://www.111cn.net/wy/yw.html
相关文章推荐
- 【文件检索0.02】实现了支持任何文件都可以统计个数而非限制于MP4,但是少了统计视频长度
- 限制内容长度(CSS,jQuery)
- FCKeditor 编辑器插入代码功能实现步骤
- js实现统计录入文本框中的字符的个数,并加以限制
- Android-EditText仿QQ名称限制内容长度中文占2个长度
- 微信公众帐号开发教程第6篇-文本消息的内容长度限制揭秘
- 一行代码保存fckeditor编辑器提交的内容到文件(接上一博)
- 利用HTC技术限制多行输入框的内容的长度
- jQuery实现限制文本框的输入长度
- CSS实现内容超过长度后以省略号显示
- 实现sharepoint 内容编辑器直接上传图片功能
- 如何实现在线人数统计和登录限制?
- 关于FCKEditor编辑器标题图片功能的实现
- 在Linux vim编辑器中实现左边目录,右边内容布局的方法。
- CSS实现内容超过长度后以省略号显示
- 限制input内容长度
- ios UITextField UITextView 限制内容长度
- 答题框:EditText输入长度、输入内容的限制。