FCKEidtor 自动统计输入字符个数(IE)
导读:收集整理的这篇文章主要介绍了FCKEidtor 自动统计输入字符个数(IE ,觉得挺不错的,现在分享给大家,也给大家做个参考。 此方法支持IE 不支持火狐。可能是因为fcKeidtor的...
收集整理的这篇文章主要介绍了FCKEidtor 自动统计输入字符个数(IE),觉得挺不错的,现在分享给大家,也给大家做个参考。 此方法支持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个字符数 提示
@H_512_65@
點擊【確定】后 自動截取100個字符
您可能感兴趣的文章:
- linux下wc统计文件的个数、行数、字数、字节数等信息方法
- C++统计中英文大小写字母、数字、空格及其他字符个数的方法
- C语言编程中统计输入的行数以及单词个数的方法
- c++统计文件中字符个数代码汇总
- C语言统计字符个数代码分享
- C语言统计一串字符中空格键、Tab键、回车键、字母、数字及其他字符的个数(Ctrl+Z终止输入)
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: FCKEidtor 自动统计输入字符个数(IE)
本文地址: https://pptw.com/jishu/608196.html
