0
我有一个函数可以在按下时获取关键代码。firefox中的事件“e is undefined”
这里是我的代码:
function Getkeycode(e){
var keycode = null;
if (window.event)
keycode = window.event.keyCode;
else
keycode = e.which;
return keycode;
}
window.onkeydown = function(){
alert(Getkeycode()); // I'm tried to using Getkeycode() or Getkeycode(e) but still error
}
前面的代码运行良好在Internet Explorer,但在Firefox中总是出现错误信息>>e is undefined
或e is not defined
通“E”,同时呼吁Getkeycode(E) – Apurv