百度编辑器UEditor超出最大字数后不能完整保存解决方法

2022-08-18 333

想要实现在达到最大字数的时候,就禁止再继续输入了或者超出字数限制后,不能完整保存内容。

查阅很多资料,六久阁总结解决方法如下:

第一步:在/include/ueditor/ueditor.all.js中找到这两行注释掉

countDom.innerHTML = errMsg;

editor.fireEvent(“wordcountoverflow”)

第二步:在注释点的两行下面写上这三行就搞定了

var content = editor.getContentTxt();

editor.setContent(content.substring(0,max));

editor.focus(true);