2013-04-15 19 views
5

Có bất kỳ phương án thay thế nào cho -tên web-touch-callout, hoạt động trên điện thoại di động dựa trên Android hay không. Tôi đang cố vô hiệu hóa cửa sổ bật lên cảm ứng dài trong thiết bị di động. Tôi đã cố gắng để ràng buộc jQuerys taphold sự kiện để trả về false; nhưng không có may mắn ... Bất kỳ ý tưởng nào? Cảm ơn!CSS: các tùy chọn thay thế chú thích-webkit-touch-call cho android

+0

bạn có thể sử dụng "e.preventDefault()" trên các sự kiện touchstart. – Smeagol

+0

http://stackoverflow.com/questions/15012702/webkit-touch-callout-equivalent-for-ie – Alvaro

Trả lời

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> 

Nguồn: Disabling the context menu on long taps on Android