Long Tap pops up context menu


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

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

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


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.


The MDN docs have a warning about this:

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.

closed #4

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