【问题标题】:Ext.getBody().focus() not working in IE6Ext.getBody().focus() 在 IE6 中不起作用
【发布时间】:2015-11-05 03:40:58
【问题描述】:

Ext.getBody().focus() 在 IE6 中似乎无法正常工作。当用户导航到新的 ExtJS 选项卡时,我需要确保他不能再键入他可能正在输入的 CKEditor 实例(导航到新选项卡后隐藏)。以下代码适用于 FF,但不适用于 IE6。

for( var instanceName in CKEDITOR.instances ) {
    CKEDITOR.instances[instanceName].focusManager.forceBlur();  // also 
                                                                // not working 
                                                                // in IE6
}
Ext.getBody().focus();

有什么建议吗?

【问题讨论】:

    标签: javascript extjs ckeditor focus internet-explorer-6


    【解决方案1】:

    我相信包括 IE 6 在内的所有主流浏览器都支持 document.activeElement 属性。如果我理解正确,您需要在用户单击选项卡时从活动表单元素中移除焦点?假设您可以在单击选项卡时访问某种事件,请尝试以下操作:

    if(document.activeElement) {
        //Call blur() to remove focus from the active (focused) element
        document.activeElement.blur(); 
    }
    

    如果您想禁用该字段的所有输入,您还想给它“禁用”属性。

    【讨论】:

    • 感谢您的回复。这也不起作用 - 可能是因为“当前”焦点位于 iFrame 中。
    • 我相信它仍然可以工作,如果它在 iframe 中,您只需要获取 it's 文档对象:window.frames['your_frame'].document.activeElement
    【解决方案2】:

    我使用了这个解决方法;我创建了一个零高度和零宽度的输入字段,并将焦点移到该字段以模糊 CKEditor 字段/实例。

    【讨论】:

      猜你喜欢
      • 2013-07-03
      • 1970-01-01
      • 2023-03-31
      • 2015-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多