ie9RC版兼容性

<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上无反应,不知道如何解决

慕码人8056858
浏览 478回答 1
1回答

森栏

input.onkeydown = function(e) {   e = e|| window.event;   //用e来代替window.event}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript