在Android上禁用标注(上下文菜单) [英] Disable callout (context menu) on Android

查看:196
本文介绍了在Android上禁用标注(上下文菜单)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In a web app, I need to disable the default callout that mobile browsers shows when touching and holding ("long tap") on a touch target, such as an <img> or a link.

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

I am already using -webkit-touch-callout: none; which works fine on iPhone and iPad, but doesn't seem to work on Android (tested on Android 4.4).

这篇文章建议在Javascript中为contextmenu事件添加一个监听器并调用 e.preventDefault()。这似乎也不起作用。

This post from the W3 mailing list suggests adding a listener for the "contextmenu" event in Javascript and calling e.preventDefault(). This does not seem to work either.

有什么建议吗?

推荐答案

您可以尝试这样做:

window.oncontextmenu = function(event) {
     event.preventDefault();
     event.stopPropagation();
     return false;
};

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

I hope this is useful...

Doc oncontextmenu

这篇关于在Android上禁用标注(上下文菜单)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆