kindeditor限制html长度的问题
<html>
<head>
<script charset="utf-8" src="/kindeditor/kindeditor_min.js" type="text/javascript"></script>
</head>
<body>
<textarea id="Description" cols="100" rows="8" style="width: 700px; height: 400px;visibility: hidden;" runat="server"></textarea>
<br />
<span id="spRemaining" style="color:green"></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>