Disable callout (context menu) on Android

android, css, html, touch, web-applications

Solution

You can try to do this :

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

I hope this is useful...

Doc oncontextmenu

Problem

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. 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). 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. Any suggestions?

Original source