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?
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.
You can try to do this :
window.oncontextmenu = function(event) { event.preventDefault(); event.stopPropagation(); return false; };
I hope this is useful...
Doc oncontextmenu
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With