js判断鼠标左,中,右键哪个被点击
推荐于2016-10-16
展开全部
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
RunJS 演示代码
</title>
<script>
document.onmousedown=function(e){
e = e || window.event;
var btn = e.button + 1 || e.which;
if(btn == 1){
console.log("左键");
}else if(btn==2){
console.log("中键");
}else if(btn==3){
console.log("右键");
}
}
document.oncontextmenu=new Function("return false");
</script>
</head>
<body>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询