【问题标题】:How to detect right mouse click while left mouse button is pressed in IE?如何在IE中按下鼠标左键时检测鼠标右键单击?
【发布时间】:2010-10-18 16:30:41
【问题描述】:

我有以下:

<html>
<body oncontextmenu="return false;">
    <script src="jquery-1.3.2.min.js"></script>
    <script>
        $(document).ready(function () {
            $(document).mousedown(function (e) {
                if (e.button == 2) //right click
                {
                    document.body.style.backgroundColor = "green";
                }
                else //left click
                {
                    document.body.style.backgroundColor = "blue";
                }
            });
        });
    </script>
</body>
</html>

如果在按住鼠标左键的同时单击鼠标右键,则预期的行为是背景颜色从蓝色变为绿色。

这在 Firefox 中有效,但我不确定如何在 IE (7) 中使其有效。谢谢!

【问题讨论】:

    标签: javascript jquery html internet-explorer


    【解决方案1】:

    鼠标右键+左键设置e.button==3不是2。

    【讨论】:

    • 谢谢!我应该假设 IE & FF 中的 e.button 值不同..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    相关资源
    最近更新 更多