Long Tap pops up context menu


#1

Hi
How to disable popup context menu showing COPY SHARE options when you tap and keep pressed on the form, pictures…?

I found and tried this

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

it partially works: there is no popping up menu but still i can see the text selected and highlighted.
Thanks


#2

Hi
I found a better fix that solves completely the problem (for me, I hope for you too):

document.documentElement.style.webkitTouchCallout = "none"
document.documentElement.style.webkitUserSelect = "none"

No popup, no selected text… and the rest works normally.


#3

The MDN docs have a warning about this:

Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

for webkitUserSelect, it says,

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.


#4

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.