ExtJs事件传播在firefox上“不可阻挡”

时间:2014-01-14 10:32:11

标签: javascript firefox javascript-events extjs4

我试图在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

1 个答案:

答案 0 :(得分:0)

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