Orb*_*ter 13 iphone jquery scroll smartphone
我使用以下代码禁用桌面浏览器中的滚动,但它不适用于iPhone屏幕分辨率.
$("html").css("overflow", "hidden");
Run Code Online (Sandbox Code Playgroud)
还需要添加什么?
Fre*_*all 28
//target the entire page, and listen for touch events
$('html, body').on('touchstart touchmove', function(e){
//prevent native touch activity like scrolling
e.preventDefault();
});
Run Code Online (Sandbox Code Playgroud)
如果触摸事件被阻止对您不起作用,您可以像这样:
html, body{
max-width:100%;
max-height:100%;
overflow:hidden;
}
Run Code Online (Sandbox Code Playgroud)
我将提供一个不使用jQuery的片段,所以下一个"Javascripter"可以只复制'n'糊状:
var defaultPrevent=function(e){e.preventDefault();}
document.body.parentElement.addEventListener("touchstart", defaultPrevent);
document.body.parentElement.addEventListener("touchmove" , defaultPrevent);
document.body.addEventListener("touchstart", defaultPrevent);
document.body.addEventListener("touchmove" , defaultPrevent);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
35096 次 |
最近记录: |