是否可以防止使用JavaScript的触摸屏显示器,平板电脑,手机上的触摸手势?

最佳答案

您可以通过防止touchstart事件来做到这一点。如果要在整个页面上进行操作,则可能要在身体上进行操作。

var body = document.body;
element.ontouchstart = function(e) {
    e.preventDefault();
}


您也可以将window.addEventListener用于整个页面。

window.addEventListener('touchstart', function(e) {
    e.preventDefault();
}


这也将允许其他人加入touchstart事件。

jQuery的

也可以通过on方法使用jQuery。

$('body').on('touchstart', function(e) {
    e.preventDefault();
});

10-08 15:03