头痛了好长时间,IE的BUG,富文本编辑器在IE下容易失去焦点,导致整个页面的控件都无法获取焦点,其他浏览器正常,而且所有的富文本编辑器都有这问题,因为加载原理都是一样的,都是在页面创建iFrame,问题就出在这。
在网上也搜过一些解决方法,都没有起到作用,不知道为何。
有一个简单的方案,在dwz.ui.js中找到编辑器初始化的代码,增加如下代码即可:
if ($.fn.xheditor) {
$("textarea.editor", $p).each(function () {
var $this = $(this);
var op = { html5Upload: false, skin: 'vista', tools: $this.attr("tools") || 'full' };
var upAttrs = [
["upLinkUrl", "upLinkExt", "zip,rar,txt,xls,xlsx,doc,docx", "../xheditor/xeditor_up.ashx?immediate=1"],
["upImgUrl", "upImgExt", "jpg,jpeg,gif,png", "../xheditor/xeditor_up.ashx?immediate=1"],
["upFlashUrl", "upFlashExt", "swf", "../xheditor/xeditor_up.ashx?immediate=1"],
["upMediaUrl", "upMediaExt", "avi", "../xheditor/xeditor_up.ashx?immediate=1"]
];
$(upAttrs).each(function (i) {
var urlAttr = upAttrs[i][0];
var extAttr = upAttrs[i][1];
// if ($this.attr(urlAttr)) {
op[urlAttr] = $this.attr(urlAttr) || upAttrs[i][3];
op[extAttr] = $this.attr(extAttr) || upAttrs[i][2];
// }
});
$this.xheditor(op);
<span style="background-color: rgb(255, 255, 102);"> $this.focus();</span>
});
}
$("textarea.kindeditor", $p).each(function () {
var $this = $(this);
$.getScript('editor/kindeditor.js', function () {
KindEditor.basePath = 'editor/';
var editor = KindEditor.create($this, {
uploadJson: '_ashx/upload_json.ashx',
fileManagerJson: '_ashx/upload_json.ashx',
allowFileManager: true,
afterBlur: function () { this.sync(); },
afterCreate: function () {
var self = this;
KindEditor.ctrl(document, 13, function () {
self.sync();
K('form[name=Form1]')[0].submit();
});
KindEditor.ctrl(self.edit.doc, 13, function () {
self.sync();
KindEditor('form[name=Form1]')[0].submit();
});
}
});
});
<span style="background-color: rgb(255, 255, 153);"> $this.focus();</span>
});