信息发布→ 登录 注册 退出

百度UEditor修改右下角统计字数包含html样式

发布时间:2026-01-11

点击量:

百度UEditor修改右下角统计字数默认只统计前台所见的文字个数,为了便于展示实际保存的时候是保存的包含html标签的,所以右下角的统计字数功能需要修改

/**
* 计算编辑器当前内容的长度
* @name getContentLength
* @grammar editor.getContentLength(ingoneHtml,tagNames) =>
* @example
* editor.getLang(true)
* 
* 2013年7月1日16:53:15 注释掉的内容为 去除html标记后的内容数,实际入库是算上html标签和文字的 所以统计字数以getContents为准
*/
getContentLength: function (ingoneHtml, tagNames) {
var count = this.getContent(false,false,true).length;
/*if (ingoneHtml) {
tagNames = (tagNames || []).concat([ 'hr', 'img', 'iframe']);
count = this.getContentTxt().replace(/[\t\r\n]+/g, '').length;
for (var i = 0, ci; ci = tagNames[i++];) {
count += this.document.getElementsByTagName(ci).length;
}
}*/
return count;

},

找到ueditor.all.js这个文件 找到4944行到4951行 注释掉 就ok了

标签:# class  # ci  # getElementsByTagName  # document  # getContentLength  # js  # editor  # grammar  # brush  # html  # UEditor  # 百度UEditor  # pre  # ingoneHtml  # 是算上  # gt  # tagNames  # getLang  # true  # 编辑器  # 所见  # 统计字数  
在线客服
服务热线

服务热线

4008888355

微信咨询
二维码
返回顶部
×二维码

截屏,微信识别二维码

打开微信

微信号已复制,请打开微信添加咨询详情!