【问题标题】:ExtJs event propagation "unstoppable" on FirefoxExtJs 事件传播在 Firefox 上“不可阻挡”
【发布时间】:2014-01-14 10:32:11
【问题描述】:

我试图阻止在 ExtJs 应用程序中按退格键时返回导航。到目前为止,我有以下代码:

Ext.EventManager.on(window, 'keydown', function (e, t) {
    if (e.getKey() == e.BACKSPACE && (!/^(input|text|password|file|textarea)$/i.test(t.tagName.toLowerCase()) || t.disabled || t.readOnly || /^button$/i.test(t.type.toLowerCase()))) {
        if (!confirm("Are you sure you want to navigate back ?")) {
            if (e.preventDefault) {
                e.preventDefault();
                e.stopPropagation();
            } else {
                e.returnValue = false;
            }
        }    
    }
});

问题是在 Chrome 和 IE 上它可以正常工作,但在 Firefox 上导航不会被阻止。 我试过了:

e.stopImmediateProgpagation()
e.stopEvent()
e.cancelBubble = true;
return false;

但它们似乎都不起作用。你能帮我解决这个问题吗? PS:我用的是ExtJs4.0.7

【问题讨论】:

  • 设置延迟和停止事件:Ext.EventManager.on(window, 'keydown', function(){...}, null, { delay: 1, stopEvent: true });

标签: javascript firefox dom-events extjs4


【解决方案1】:

看起来有必要将侦听器添加到“keypress”事件以使其工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 2013-02-17
    • 1970-01-01
    • 2012-12-30
    • 2013-07-10
    • 1970-01-01
    相关资源
    最近更新 更多