在Android上禁用标注(上下文菜单)

Gro*_*uez 22 html5 android web-applications touch css3

在Web应用程序中,我需要禁用移动浏览器在触摸目标(例如<img>或链接)上触摸并按住("长按")时显示的默认标注.

我已经-webkit-touch-callout: none;在iPhone和iPad上正常使用它,但似乎不适用于Android(在Android 4.4上测试过).

来自W3邮件列表的这篇文章建议在Javascript和调用中为"contextmenu"事件添加一个监听器e.preventDefault().这似乎也不起作用.

有什么建议?

Zag*_*ine 6

您可以尝试这样做:

window.oncontextmenu = function(event) {
     event.preventDefault();
     event.stopPropagation();
     return false;
};
Run Code Online (Sandbox Code Playgroud)

我希望这很有用......

Doc oncontextmenu