kindeditor限制html长度的问题

 

<html>

<head>

<script charset=”utf-8″ src=”/kindeditor/kindeditor_min.js” type=”text/javascript”></script>

</head>

<body>

<textarea ></span>

</body>

<script type=”text/javascript”>

var keditor;
$(function () {
//判断是否超过。
var whetherMoreThan = 0;

var keoptions = {
minWidth: 585,
filterMode: true,
indentChar: ‘ ‘,
cssPath: ‘/kindeditor/plugins/code/prettify.css’,
uploadJson: ‘/kindeditor/asp.net/upload_json.ashx’,
fileManagerJson: ‘/kindeditor/asp.net/file_manager_json.ashx’,
allowImageUpload: true,
allowFlashUpload: false,
allowMediaUpload: false,
allowFileManager: true,
allowImageRemote: true,
fillDescAfterUploadImage: true,
afterCreate: function() {
var self = this;
KindEditor.ctrl(document, 13, function() {
self.sync();
KindEditor(‘form1’)[0].submit();
});
KindEditor.ctrl(self.edit.doc, 13, function() {
self.sync();
KindEditor(‘form1’)[0].submit();
});
}, afterChange: function () {
var limitNum = 8000; //设定最大长度数
if (this.count() > limitNum) { //限制html的长度
// if (this.count(“text”) > limitNum) { //限制文本的长度
//alert(“超过最大长度”);
document.getElementById(“spRemaining”).style.color = “red”;
document.getElementById(“spRemaining”).innerHTML = “已经超过最大值,不属于在输入”;
//取上一次的值。
var Descriptionvalue =document.getElementById(“Description”).value;
this.html(Descriptionvalue);
whetherMoreThan = 1;
}
else {
//未了让他不显示剩余位置。
if (whetherMoreThan == 1) {
whetherMoreThan = 0;
}
else {
document.getElementById(“spRemaining”).style.color = “green”;
document.getElementById(“spRemaining”).innerHTML = “剩余字数” + (limitNum – this.count());
}
//把值同步到textarea
this.sync(“Description”);
}
}
};

keoptions = $.extend(keoptions, ketoolbase);
keditor = KindEditor.create(‘#Description’, keoptions);
});

</script>

</html>

 

原文链接:https://www.cnblogs.com/zhian/p/4975334.html
本文来源 爱码网,其版权均为 原网址 所有 与本站无关,文章内容系作者个人观点,不代表 本站 对观点赞同或支持。如需转载,请注明文章来源。

© 版权声明

相关文章