我知道那里有很多解决方案,但无法找到正确的解决方案。我已经在tinyMCE版本3中为自定义计数器编写了代码,该版本的maxlength属性不起作用。我想在计数器达到0时停止提供更多文本setcontent(""),substring(0,maxcount)这似乎是有问题的,因为当我在其修剪后两个字符之间输入任意2个字符时,这种方式不应该这样。我也尝试过使用evt.preventDefault()它的阻止功能,但无法再次输入IN进行击键,而击键也排除了bacspace和delete,但它无法正常工作。这是我的代码。
tinyMCE.init({
mode: "textareas",
theme: "advanced",
editor_selector: "mceEditor",
paste_auto_cleanup_on_paste: 'true',
theme_advanced_disable: 'justifyleft,justifyright,justifyfull,justifycenter,indent,image,anchor,sub,sup,unlink,outdent,help,removeformat,link,fontselect,hr,styleselect,formatselect,charmap,separator,code,visualaid,strikethrough,fullscreen',
theme_advanced_buttons1: 'bold,italic,underline,numlist,bullist,undo,redo,cleanup,spellchecker',
theme_advanced_buttons2: "",
theme_advanced_buttons3: "",
plugins: 'spellchecker,fullscreen,paste',
spellchecker_languages: '+English=en-us',
spellchecker_rpc_url: '<%out.print(request.getContextPath());%>/jazzy-spellchecker',
theme_advanced_statusbar_location: "bottom",
theme_advanced_path : false,
statusbar: true,
setup: function(editor)
{
editor.onKeyUp.add(function(evt)
{
var maxLengthRichTextArea = 5;
var inputRichTextArea = $(editor.getBody()).text();
var inputRichTextAreaLength = inputRichTextArea.length;
var value = maxLengthRichTextArea-inputRichTextAreaLength;
if(value >= 0)
{
$(tinyMCE.activeEditor.getContainer()).find("#"+editor.id+"_path_row").html("Remaining chars: "+(value));
}
});
}
});
</script>
的HTML
<textarea id="450225" class="mceEditor" maxlength="10" style="display: none;"></textarea>
HUWWW
相关分类