首页 > windows8触摸屏下如何禁止在目标dom上手指上下滑动时页面滚动

windows8触摸屏下如何禁止在目标dom上手指上下滑动时页面滚动

在手机上处理正常的touchstart,touchmove,touchend事件,在windows8触摸屏上就不行了,会触发整个网页的上下滚动(touchmove中已经event.preventDefault())不再触发touchmove事件

请问如何禁止在目标dom上手指上下滑动时页面滚动?

浏览器是ie11

代码如下

var canvas = $('#canvas');
canvas.on('touchstart', onTouchStart);
$(document).on('touchend', onTouchEnd);

function onTouchStart(event) {
    event.preventDefault();
    //do something
    canvas.on('touchmove', onTouch);
}

function onTouchMove(event) {
    //手机上正常阻止浏览器滑动的代码,在win8触摸屏上失效了
    event.preventDefault && event.preventDefault();
    //do something
}

function onTouchEnd(event) {
    event.preventDefault();
    canvas.off('touchend', onTouchMove);
}
【热门文章】
【热门文章】