FCKEidtor 自动统计输入字符个数(IE)
时间:2023-01-28 10:07:54
此方法支持IE 不支持火狐。可能是因为FCKEidtor的keyup方法在火狐下不被支持。
FCKEditor编辑器换为TextBox,应该就没有问题了。
前台:
<tr>
<th>
短敘述
<br />
(限100中文字)<br />
當前文字個數:<asp:Label ID="lblShowTextLength" runat="server" Text="0" ForeColor="Red"></asp:Label><br />
</th>
<td style="text-align: left;">
<FCKeditorV2:FCKeditor ID="fckPrdDescription" runat="server" Height="240px" Width="100%">
</FCKeditorV2:FCKeditor>
</td>
</tr>
JS代码:
<script type="text/javascript">
function FCKeditor_OnComplete(editorInstance)
{
var oEditor = FCKeditorAPI.GetInstance('fckPrdDescription');
oEditor.EditorDocument.body.onkeyup=function ()
{
if( document.all)
{
$("lblShowTextLength").innerText =oEditor.EditorDocument.body.innerText.length;
}
else
{
var r = oEditor.EditorDocument.createRange() ;
r.selectNodeContents( oEditor.EditorDocument.body ) ;
$("lblShowTextLength").innerText= r.toString().length ;
}
if(parseInt($("lblShowTextLength").innerText)>100)
{
alert("當前已經達到100中文字,請不要繼續輸入!");
oEditor.EditorDocument.body.innerText=oEditor.EditorDocument.body.innerText.substring(0,100);
$("lblShowTextLength").innerText =oEditor.EditorDocument.body.innerText.length;
}
// $("ddd").value =oEditor.EditorDocument.body.innerHTML;
}
if (document.getElementById("hidStatus").value=="Cancel")
{
editorInstance.EditorDocument.designMode="off";
}
}
</script>
點擊【確定】后 自動截取100個字符
标签:FCKEidtor,自动统计,字符个数
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
CentOS下安装Memcached和PHP Memcached扩展
2023-11-14 14:50:19
JS 显示当前日期+星期(静态)
2007-09-11 13:29:00
Vue $emit()不能触发父组件方法的原因及解决
2024-05-28 16:10:26
在PyCharm中三步完成PyPy解释器的配置的方法
2021-02-20 04:12:17
![](https://img.aspxhome.com/file/2023/8/101208_0s.jpg)
Django文件存储 自己定制存储系统解析
2023-09-17 13:06:25
python实现登录与注册系统
2022-04-26 02:32:38
![](https://img.aspxhome.com/file/2023/8/68328_0s.jpg)
基于网格的网页设计概念及实际应用案例
2010-03-30 14:59:00
![](https://img.aspxhome.com/file/UploadPic/20103/30/1052570-42s.jpg)
Python3网络爬虫之使用User Agent和代理IP隐藏身份
2022-03-05 13:13:07
![](https://img.aspxhome.com/file/2023/5/79625_0s.png)
Python的线程之线程同步
2021-02-05 23:23:32
![](https://img.aspxhome.com/file/2023/5/135145_0s.jpg)
详解Python多线程Selenium跨浏览器测试
2023-05-05 08:10:11
![](https://img.aspxhome.com/file/2023/8/115608_0s.png)
Python %r和%s区别代码实例解析
2023-10-07 17:01:08
关于Flask 上下文详细介绍
2023-12-10 01:52:32
![](https://img.aspxhome.com/file/2023/7/85087_0s.png)
Python多线程、异步+多进程爬虫实现代码
2023-07-29 03:28:42
Mootools 1.2教程(21)——类(二)
2008-12-28 20:58:00
Python迭代器和生成器定义与用法示例
2022-02-15 19:42:13
Python全面分析系统的时域特性和频率域特性
2022-12-04 06:32:12
![](https://img.aspxhome.com/file/2023/7/113137_0s.jpg)
Pytorch关于Dataset 的数据处理
2021-04-16 08:40:54
![](https://img.aspxhome.com/file/2023/1/84901_0s.png)
asp日期函数运用--生成简单的日历
2008-08-15 13:47:00
![](https://img.aspxhome.com/file/UploadPic/20088/15/2008815134819595s.gif)
如何提升JavaScript的运行速度(递归篇)
2010-05-17 13:30:00
python抽象基类用法实例分析
2021-03-04 11:06:25