IE中的事件未定义,可在Firefox中使用 [英] Event is Undefined in IE works in Firefox

查看:114
本文介绍了IE中的事件未定义,可在Firefox中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文本框中有onKeypress事件,这在FireFox中有效,而在IE中则没有

I have onKeypress Event in Text Box This Works in FireFox, does not in IE

事件在IE中传递为未定义

event is passed as undefined in IE

PriceInBox.onkeypress = function(event) { return moZoltarCurrent.evt_checkForInt(event); }

推荐答案

您需要规范化事件接口,例如IE

You need to normalize the Event interface, as IE doesn't pass it along as a parameter, but uses a global variable:

PriceInBox.onkeypress = function(event) {
    event = event || window.event;
    return moZoltarCurrent.evt_checkForInt(event);
};

这篇关于IE中的事件未定义,可在Firefox中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆