gpt4 book ai didi

javascript - 如何在 IE 中检测鼠标右键单击并按下鼠标左键?

转载 作者:行者123 更新时间:2023-12-01 05:11:19 24 4
gpt4 key购买 nike

我有以下内容:

<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) 中工作。谢谢!

最佳答案

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

关于javascript - 如何在 IE 中检测鼠标右键单击并按下鼠标左键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/736281/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com