1.整个页面所有的右击事件

document.oncontextmenu = function(){
  return false;
}

 

2.特定的区域

document.getElementById("test").oncontextmenu = function(e){
  return false;
}

 

3.去掉后可以给喜欢区块加特定的事件

js:

document.getElementById("test").onmousedown = function(e){
  if(e.button ==2){
    alert("你点了右键");
  }else if(e.button ==0){
    alert("你点了左键");
  }else if(e.button ==1){
    alert("你点了滚轮");
  }
}

jq:

$("#test").mousedown(function(e){
  //doing
});

 

4.通过jq  bind 绑定 和 触发

$('').bind("contextmenu",function (e){

   //doning

   return false;

});

$('').trigger('contextmenu');

相关文章:

  • 2021-11-30
  • 2021-08-17
  • 2021-12-06
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
猜你喜欢
  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2021-08-23
相关资源
相似解决方案