我正在将应用程序移植到 JavaScript/CSS,它使用右键单击。出于某种原因,适用于 Windows 的 Firefox 3.6 不会发出右键单击事件,但 Chrome 和 IE 会发出。这是一些测试代码。如果您右键单击 #test
,那么您在 Firefox 中什么也得不到,但在 Chrome 和 IE 下您会收到警告。
<html>
<head>
<title>Hi</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("#test").get(0).oncontextmenu = function() { return false; };
$("#test").mousedown(function() { alert("hi"); });
});
</script>
</head>
<body>
<div id="test" style="background: red;">Hi</div>
</body>
</html>
为什么在 Firefox 中不生成右键单击事件?
最佳答案
我发现了问题。我安装了“多合一手势”扩展。我尝试在禁用它的情况下运行代码并且它工作正常。看起来像是扩展的错误/限制。
更新:我刚刚尝试了“Mouse Gestures Redox”扩展,它没有这个问题。
关于javascript - Firefox 3.6 没有右键单击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2444151/