$(function () {
//防止畫面下滑刷新
const target = window;
let lastY = 0;
target.addEventListener('touchmove', handleTouchMove);
function handleTouchMove(e) {
const { pageY } = e.changedTouches[0];
const scrollY = target.pageYOffset || target.scrollTop || 0;
if (pageY > lastY && scrollY === 0) {
e.preventDefault();
}
lastY = pageY;
}
//防止页面后退
history.pushState(null, null, document.URL);
window.addEventListener('popstate', function () {
history.pushState(null, null, document.URL);
});
});