在IE8中,jQuery mousedown事件没有为窗口触发

Noc*_*las 1 javascript jquery javascript-events internet-explorer-8

我在使用IE8中的jQuery挂钩窗口的mousedown事件时遇到了问题.我没有得到任何错误,但事件似乎没有被解雇.它在IE9和我尝试过的所有其他浏览器中都有效.这是我的代码:

<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function test(e) {
            alert('test');
        }

        $(document).ready(function () {
            $(window).mousedown(test);
        });     
    </script>   
</head>
<body>   
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

Cha*_*mal 5

document而不是window

$(document).ready(function() {
    $(document).mousedown(function() {
        alert('test');
    });
});
Run Code Online (Sandbox Code Playgroud)