Disable Firefox's silly right click context menu

天大地大妈咪最大 提交于 2019-12-06 03:33:28
dainichi

You will never be able to entirely disable the context menu in all cases, as firefox has a setting that allows the user to tell the browser to ignore such hijinx as you are trying to pull.

Note: I'm on a mac, but this setting is in pretty uch the same place over all platforms.

That being said, try event.preventDefault() (see Vikash Madhow's comment on this other SO question: How to disable right-click context-menu in javascript)

There is actually example in official documentation that blocks directly context menu event:

document.oncontextmenu = function () { // Use document as opposed to window for IE8 compatibility
  return false;
};

window.addEventListener('contextmenu', function (e) { // Not compatible with IE < 9
  e.preventDefault();
}, false);
spksa
document.ondblclick = function(e) { 
    if(e.button == 2 || e.button == 3) {
        e.preventDefault();
        e.stopPropagation();
        return(false);
    }
};
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!