Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: -webkit-touch-callout alternatives for android

Is there any alternative for -webkit-touch-callout, which works on Android based mobiles. I'm trying to disable the long touch popup in mobile devices. I've tried to bind jQuerys taphold event to return false; but no luck... Any idea? Thanks!

like image 671
Kopacz Levente Avatar asked Apr 15 '13 08:04

Kopacz Levente


1 Answers

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

Source: Disabling the context menu on long taps on Android

like image 117
tracyak13 Avatar answered Nov 09 '22 05:11

tracyak13