解决办法如下:
方法一:
<link rel="stylesheet" href="../include/kindeditor/themes/default/default.CSS" />
<link rel="stylesheet" href="../include/kindeditor/plugins/code/PRettify.css" />
<script charset="utf-8" src="../include/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="../include/kindeditor/lang/zh_CN.js"></script>
<script charset="utf-8" src="../include/kindeditor/plugins/code/prettify.js"></script>
<script type="text/javascript">
KindEditor.ready(function(K) {
var editor1 = K.create('textarea[name="content"]', {
cssPath : '../include/kindeditor/plugins/code/prettify.css',
uploadJson : '../include/kindeditor/php/upload_json.php',
fileManagerJson : '../include/kindeditor/php/file_manager_json.php',
allowFileManager : true,
afterCreate : function() {
var self = this;
K.ctrl(document, 13, function() {
self.sync();
K('form[name=example]')[0].submit();
});
K.ctrl(self.edit.doc, 13, function() {
self.sync();
K('form[name=example]')[0].submit();
});
},afterBlur: function(){this.sync();}
});
prettyPrint();
});
</script>
在默认的代码中,增加如上红色代码
方法二:
原 KindEditor 官方指定调用参数如下,在IE浏览器6.0-7.0都是没有问题的
KindEditor.ready(function(K) {var editor = K.create('textarea[name="content"]', {cssPath : '样式路径',uploadJson : '动态上传处理程序文件',fileManagerJson : '已上传文件管理程序文件',allowFileManager : true,afterCreate : function() {var self = this;K.ctrl(document, 13, function() {self.sync();K('form[name=myform]')[0].submit();});K.ctrl(self.edit.doc, 13, function() {self.sync();K('form[name=myform]')[0].submit();});}});prettyPrint();});
红色代码部分替换为如下绿色代码:
KindEditor.ready(function(K) {var editor = K.create('textarea[id="content"]', {cssPath : '样式路径',uploadJson : '动态上传处理程序文件',fileManagerJson : '已上传文件管理程序文件',allowFileManager : true,afterBlur : function() {this.sync();K.ctrl(document, 13, function() {K('form[name=myform]')[0].submit();});K.ctrl(this.edit.doc, 13, function() {K('form[name=myform]')[0].submit();});}});prettyPrint();});
注:当失去焦点时执行 this.sync();关于 this.sync() 函数简单的说就是同步KindEditor的值到textarea文本域。
新闻热点
疑难解答