/** 解決 ios瀏覽器頁面滾動到底部或頂部后 導致頁面局部滑動失效的問題*/ function iosTrouchFn () { var ios = navigator.userAgent.indexOf('iPhone'); // 判斷是否為ios if (ios !== -1) { // ios下運行 var el = document.querySelector('body'); // el -- 需要滑動的元素 el.addEventListener('touchmove', function (e) { if (el.offsetHeight < el.scrollHeight) e.isSCROLL = true; }); document.body.addEventListener('touchmove', function (e) { if (!e.isSCROLL) e.preventDefault(); // 阻止默認事件(上下滑動) }); } }