Disable Longpress Action On Mobile With Javascript
in this period,I make some new webApps, but I have a big problem with drag and drop. I write a file manager in javascript, but when on mobile (smartphone, tablet andorid or iOs) I
Solution 1:
-webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */
-webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */
Solution 2:
check the value of navigator.userAgent
and compare with android|iphone|ipad etc and in your java script you could do the following
function init() {
onLongPress(document.getElementById('element'));
}
function onLongPress(node) {
node.ontouchstart = nullEvent;
node.ontouchend = nullEvent;
node.ontouchcancel = nullEvent;
node.ontouchmove = nullEvent;
}
function nullEvent(event) {
var e = event || window.event;
e.preventDefault && e.preventDefault();
e.stopPropagation && e.stopPropagation();
e.cancelBubble = true;
e.returnValue = false;
return false;
}
Post a Comment for "Disable Longpress Action On Mobile With Javascript"