禁止頁面滑動
通常靜止滑動方案:(阻止滑動事件)
window.ontouchmove=function(e){ e.preventDefault && e.preventDefault(); e.returnValue=false; e.stopPropagation && e.stopPropagation(); return false; };
有部分機型不支持以上靜止滑動方案,可使用:(點擊后頁面浮動到指定位置不動 將body的position設置為fixed)
$("#btn").click(function(){
var top=$(window).scrollTop();//這是當前滾動的頁面滾動條位置
$("body").css({
"position":"fixed",
"width":"100%",
"top":top*-1 //此處為當前需要定住的位置
});
});
允許頁面滑動:
通常允許滑動方案:(清空滑動事件即可)
window.ontouchmove="";
處理部分機型禁止滑動的允許滑動:(將body的position設置為static)
$("#btn2").click(function(){
$("body").css({
"position":"static"
});
});
