Fckeditor编辑器内容长度限制统计实现方法
网络编程 2021-07-05 12:51www.168986.cn编程入门
Fckeditor是一种大家常用的编辑器,但是他不能像网页表单那样利用document.getelementbyid能获取得到值了,它必须通过 FCKeditorAPI来操作,狼蚁网站SEO优化看看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()
}
代码如下:
<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()
}
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程