鼠标右击事件中一般要禁止掉系统本身的右键菜单,在为元素添加新的菜单;
在添加右击事件中onclick是不生效的,一般用mousedown或者mouseup事件;
鼠标左键为0,中间件为1,右键为2;
<script>
document.oncontextmenu = function(){return false};
document.getElementById('abc').onmousedown = function (e) {
console.log(e);
console.log(e.button);
}
</script>