我想将事件侦听器添加到右键单击事件中,我知道如何处理简单的单击:document.getElementById("myBtn").addEventListener("mousedown", function(){ });
那么右键单击事件呢?
发布于 2015-08-22 04:14:13
使用以下命令测试单击类型:alert("You pressed button: " + event.button)
发布于 2015-08-22 02:30:04
收听contextmenu
事件。
发布于 2018-07-24 03:51:56
<!DOCTYPE html>
<html>
<head>
<style>
div { background: yellow; border: 1px solid black; padding: 10px; }
div {
background: yellow;
border: 1px solid black;
padding: 10px;
}
</style>
</head>
<body>
<div oncontextmenu="myFunction(event)">
<p>Right-click inside this box to see the context menu!
</div>
<script>
function myFunction(e) {
e.preventDefault();
//do something differant context menu
alert("You right-clicked inside the div!");
}
</script>
<!--if it helpful visit once http://topprojects.ml for more stuf-->
</body>
</html>
https://stackoverflow.com/questions/32147108
复制相似问题