js event 2 浏览器兼容
事件编程 // js event 键盘方向键 function $(id){ return document.getElementById(id); } window.onload = function() { $('content').onkeydown = function(event) { if(window.event) { //ie var code = window.event.keyCode; } else { //w3c var code = event.keyCode; } switch(code) { case 37: alert('向左'); break; case 38: alert('向上'); break; case 39: alert('向右'); break; case 40: alert('向下'); break; } } }