【问题标题】:CSS: -webkit-touch-callout alternatives for androidCSS:-webkit-touch-callout 的 android 替代品
【发布时间】:2013-04-15 08:52:07
【问题描述】:

-webkit-touch-callout 是否有任何替代方案,它适用于基于 Android 的手机。 我正在尝试禁用移动设备中的长触摸弹出窗口。 我试图绑定 jQuerys taphold 事件以返回 false;但没有运气... 任何想法? 谢谢!

【问题讨论】:

标签: android css mobile webkit


【解决方案1】:
<!DOCTYPE html>
<html>
<head>
  <script>
    function absorbEvent_(event) {
      var e = event || window.event;
      e.preventDefault && e.preventDefault();
      e.stopPropagation && e.stopPropagation();
      e.cancelBubble = true;
      e.returnValue = false;
      return false;
    }

    function preventLongPressMenu(node) {
      node.ontouchstart = absorbEvent_;
      node.ontouchmove = absorbEvent_;
      node.ontouchend = absorbEvent_;
      node.ontouchcancel = absorbEvent_;
    }

    function init() {
      preventLongPressMenu(document.getElementById('theimage'));
    }
  </script>
</head>
<body onload="init()">
  <img id="theimage" src="http://www.google.com/logos/arthurboyd2010-hp.jpg" width="400">
</body>
</html>

来源:Disabling the context menu on long taps on Android

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-11
    • 2020-10-27
    • 2013-03-29
    • 2012-09-12
    • 2015-08-05
    相关资源
    最近更新 更多