Disable highlight/context menu on iOS

Welcome! Forums Unity Plugins In-App Web Browser Disable highlight/context menu on iOS

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2252
    dictationscratchpad
    Participant

    Hi,

    I’m trying to disable the hightlighting and/or the context menu on iOS.

    The following works on Android but not iOS. What am I doing wrong? I’m using the 2.0 version of the InAppBrowser.

    InAppBrowser.ExecuteJS("document.addEventListener('contextmenu', event => event.preventDefault());");
    InAppBrowser.ExecuteJS("document.documentElement.style['-webkit-user-select'] = 'none';");
    InAppBrowser.ExecuteJS("document.documentElement.style['-webkit-touch-callout'] = 'none';");
    InAppBrowser.ExecuteJS("document.getElementById(\"user\").addEventListener('contextmenu', event => event.preventDefault());");
    InAppBrowser.ExecuteJS("document.getElementById(\"user\").onmousedown = function(ev){if(ev.detail > 1){var e = event || window.event;e.preventDefault && e.preventDefault();e.stopPropagation && e.stopPropagation();e.cancelBubble = true;e.returnValue = false;return false;}};");
    InAppBrowser.ExecuteJS("var last = Date.now();document.getElementById(\"user\").ontouchstart = function(e){var count = e.touches.length;if (count > 1) { return; }var now = Date.now(),delta = now - (last || now);touch = e.touches ? e.touches[0] : e; doubleTap = (delta > 0 && delta <= 1500);if(doubleTap){return false;}last = now;};");
    InAppBrowser.ExecuteJS("(function loopingFunction() {var el = document.getElementById(\"user\");if(el.selectionStart != el.selectionEnd){el.selectionEnd = el.selectionStart;}setTimeout(loopingFunction, 100);})();");
    #2255
    PiotrPiotr
    Keymaster

    Hi,

    No idea – it’s question about DOM manipulation, don’t think it’s related to plugin itself.

    #2259
    dictationscratchpad
    Participant

    You’re absolutely right. Thanks.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.