The problem is that it eis undefined in IE, because the event object is not passed as an argument to the event handler. You need a property window.event:
elem.onkeypress=function(e) {
e = e || window.event;
var charCode = e.which || e.keyCode;
if (charCode == 13) {
}
};
source
share