CSS:-webkit-touch-callout替代android

时间:2013-04-15 08:52:08

标签: android css mobile webkit

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

1 个答案:

答案 0 :(得分: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