JS设置页面下拉刷新
//滑动动作 document.body.addEventListener("touchstart", touchStart, false); document.body.addEventListener("touchmove", touchMove, false); document.body.addEventListener("touchend", touchEnd, false); var canefresh = false; function touchStart(e){ if($(window).scrollTop() <= 0){ canefresh = true; } var touch = e.touches[0]; startY = touch.pageY; } function touchMove(e){ // e.preventDefault(); if(!canefresh){ return; } var touch = e.touches[0]; endY = touch.pageY; $('body').css('padding-top',endY - startY); } function touchEnd(e){ if(!canefresh){ return; } console.log(endY - startY); if((endY - startY) > 50){ location.reload(); } $('body').css('padding-top',''); canefresh = false; }