首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CSS:-webkit-touch-callout alternatives for android

CSS:-webkit-touch-callout alternatives for android
EN

Stack Overflow用户
提问于 2013-04-15 16:52:08
回答 1查看 5K关注 0票数 6

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

EN

回答 1

Stack Overflow用户

发布于 2014-06-15 00:40:08

代码语言:javascript
复制
<!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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16011159

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档