在Firefox中,IE中的事件未定义

Pra*_*een 6 javascript internet-explorer

我在文本框中有onKeypress事件这在FireFox中有效,不在IE中

事件在IE中作为未定义传递

PriceInBox.onkeypress = function(event) { return moZoltarCurrent.evt_checkForInt(event); }
Run Code Online (Sandbox Code Playgroud)

Mar*_*pel 7

您需要规范化Event接口,因为IE 不会将其作为参数传递,而是使用全局变量:

PriceInBox.onkeypress = function(event) {
    event = event || window.event;
    return moZoltarCurrent.evt_checkForInt(event);
};
Run Code Online (Sandbox Code Playgroud)