H5移动端浏览器拖动

/**
 * 禁止手机浏览器拖动
 */
function stopDefault(){
     window.ontouchmove = function(e){
         e.preventDefault && e.preventDefault();
         e.returnValue = false;
         e.stopPropagation && e.stopPropagation();
         return false;
     }
     document.body.style.height = '100%';
     document.body.style.overflow = 'hidden';
}

/*
 * 允许手机浏览器拖动
 */
function startDefault(){
     window.ontouchmove = function(e){
         e.preventDefault && e.preventDefault();
         e.returnValue = true;
         e.stopPropagation && e.stopPropagation();
         return true;
     }
     document.body.style.height = 'auto';
     document.body.style.overflow = 'auto';
}
原文地址:https://www.cnblogs.com/AnswerTheQuestion/p/8317916.html