在火狐中不支持<body onkeydown=”test()”>,要写成<body onkeydown=”test(event)”>才可以正常使用。
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body onkeydown="test(event)">
<script type="text/javascript">
function test(event){
var code = event.keycode;
alert(code)
}
</script>
</body>
</html>
在Firefox中,onkeydown方法中的event需要以参数的方式传入 而且使用的和ie的event.keycode不同使用的是event .which
不过在我更新IE到11的时候依然用的是event.which 不过不需要传入参数
达维营-前端网