简体   繁体   English

如何禁用浏览器的默认右键菜单

[英]How to disable default right click menu of browser

In my Application,in particular div ,I want to show custom right click menu with options instead of default browser menu. 在我的应用程序中,尤其是div ,我想显示带有选项的自定义右键菜单,而不是默认的浏览器菜单。

I tried with following code. 我尝试了以下代码。

events: {
   "contextmenu #navContainer":"rightClickTest"
},
rightClickTest:function(event){
 if (event.button == 2){
   alert("Right Click is not possible Here !")
  }
}

we am using backbone.js for my Application.Event is working fine but the problem is after completion of event logic,default right click menu appearing as usually. 我们在我的Application上使用了backbone.js可以正常工作,但是问题出在事件逻辑完成后,默认右键菜单通常会出现。

Note: 注意:

I want to disable default right click menu at particular div( navContainer ) of my App. 我想在我的应用程序的特定div( navContainer )上禁用默认的右键单击菜单。

How can I fix this. 我怎样才能解决这个问题。

This should do it.. 这应该做..

rightClickTest:function(event){
  if (event.button == 2){
   event.preventDefault();
   alert("Right Click is not possible Here !")
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM