FCKEidtor 自动统计输入字符个数(IE)
发布时间:2020-12-15 00:57:06 所属栏目:C语言 来源:网络整理
导读:此方法支持IE 不支持火狐。可能是因为FCKEidtor的keyup方法在火狐下不被支持。 FCKEditor编辑器换为TextBox,应该就没有问题了。 前台: 复制代码 代码如下: tr th 短⑹ br / (限100中文字)br / 前文字:asp:Label ID="lblShowTextLength" runat="server" Te
此方法支持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中文字,不要^m入!"); 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个字符数 提示
您可能感兴趣的文章:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |