Disabling the context menu on long taps on Android

Roy Sharon picture Roy Sharon · Aug 5, 2010 · Viewed 59.5k times · Source

I would like to disable the context menu that appears after a long tap (touch and hold) on images in my web application. I've seen posts with different ideas how to do it, but none of them seem to work for me.

Is there a way to do this on Android via HTML/CSS/Javascript?

Answer

bbsimonbb picture bbsimonbb · Feb 26, 2015

The context menu has its own event. You just need to catch it and stop it from propagating.

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