【问题标题】:HTML Mobile On Text Highlight Hide "Copy, Look up, Share..." Menu But Still Allow Text Highlight文本突出显示的 HTML Mobile 隐藏“复制、查找、共享...”菜单但仍允许文本突出显示
【发布时间】:2021-07-29 23:46:22
【问题描述】:

我正在关注this 教程来创建我自己的高亮上下文菜单,例如 medium.com。这可行,但在移动设备上,我的自定义突出显示菜单被隐藏,因为设备的自定义软件隐藏了它。 Here 是问题的图片:

Image Of Problem

我的代码:

document.body.addEventListener('pointerup', function(){
   // Shows my custom highlight menu
});

那我该怎么办?我想在移动设备上隐藏这个突出显示菜单,因为它隐藏了我的自定义菜单,如 image 所示。

【问题讨论】:

    标签: javascript html mobile addeventlistener highlight


    【解决方案1】:

    试试看这个问题:Disabling the context menu on long taps on Android

    一个对我有用的答案是 bbsimonbb,他的答案是:

    <style>
    html, body { 
      -webkit-touch-callout: none !important; /* disable selection/Copy of UIWebView */
      -webkit-touch-callout: none; /* disable the IOS popup when long-press on a link */
    }
    </style>
    <script>
    window.oncontextmenu = function(event) {
         event.preventDefault();
         event.stopPropagation();
         return false;
    };
    </script>
    

    如果您使用 Jquery,您也可以将其添加到上面的代码中:

    <script>
    $("body").bind('taphold', function(event) {
      event.preventDefault();
    });
    </script>
    

    【讨论】:

      猜你喜欢
      • 2013-05-28
      • 1970-01-01
      • 2013-04-05
      • 2016-12-15
      • 1970-01-01
      • 2012-03-26
      • 2019-04-29
      • 1970-01-01
      • 2011-08-31
      相关资源
      最近更新 更多