CSS:安卓的-webkit-touch-callout替代方案

6

是否有类似于-webkit-touch-callout的替代品,可以在基于Android的移动设备上使用。我正在尝试禁用移动设备上的长按弹出窗口。我尝试将jQuery的taphold事件绑定到返回false;但没有成功... 有什么想法吗?谢谢!


在touchstart事件中,您可以使用"e.preventDefault()"。 - Smeagol
https://dev59.com/WGUp5IYBdhLWcg3w1qIi - Alvaro
1个回答

2
<!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>

来源: 禁用Android长按弹出上下文菜单


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接