Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable callout (context menu) on Android

Tags:

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?

like image 924
Grodriguez Avatar asked Feb 19 '15 15:02

Grodriguez


People also ask

What is contextual menu in Android?

A context menu is a floating menu that appears when the user performs a long-click on an element. It provides actions that affect the selected content or context frame.


1 Answers

You can try to do this :

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

I hope this is useful...

Doc oncontextmenu

like image 94
Zagonine Avatar answered Oct 22 '22 12:10

Zagonine