<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function add() {
var inputs = document.getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
var input = inputs[i];
input.onkeydown = function () {
// alert(window.event.keyCode); //按回车显示为13
// alert(window.event.keyCode == 13);//显示为true
if (window.event.keyCode == 13) {
window.event.keyCode = 9;
// alert(window.event.keyCode);//显示为9
}
};
}
}
</script>
</head>
<body onload="add()">
<input id="Text1" type="text" />
<input id="Text2" type="text" />
<input id="Text4" type="text" />
<input id="Text3" type="text" />
<input id="Text5" type="text" />
</body>
</html>
在IE8上测试正常,在IE9上无反应,不知道如何解决
input.onkeydown = function(e) {
e = e|| window.event;
//用e来代替window.event
}