Reputation:
Is it possible to prevent touch gestures on a TouchScreen monitors, tablets, phones using JavaScript?
Upvotes: 1
Views: 74
Reputation: 2755
I have used a modified jQuery Block UI to do this in the past.
Upvotes: 1
Reputation: 2114
You can do it by preventing the touchstart
event. You're probably looking to do it on the body if you're doing it page-wide.
var body = document.body;
element.ontouchstart = function(e) {
e.preventDefault();
}
You can also use window.addEventListener
for a page-wide affect.
window.addEventListener('touchstart', function(e) {
e.preventDefault();
}
This will also allow others to hook into the touchstart
event.
It's also possible to do with jQuery, via the on
method.
$('body').on('touchstart', function(e) {
e.preventDefault();
});
Upvotes: 3