jquery - 如何禁用智能手机和平板电脑浏览器中的滚动?

标签 jquery iphone scroll smartphone

我使用以下代码禁用桌面浏览器中的滚动,但它不适用于 iPhone 屏幕分辨率。

$("html").css("overflow", "hidden");

我还需要添加什么吗?

最佳答案

//target the entire page, and listen for touch events
$('html, body').on('touchstart touchmove', function(e){ 
     //prevent native touch activity like scrolling
     e.preventDefault(); 
});

如果阻止触摸事件对您不起作用,您可以随时这样做:

html, body{
     max-width:100%;
     max-height:100%;
     overflow:hidden;
}

关于jquery - 如何禁用智能手机和平板电脑浏览器中的滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10097937/

相关文章:

javascript - 无法使用 jQuery Easy Slider 插件 - 请帮助

iphone - 如何在 iPhone 的 UIWebview 上显示 html 字符串?

iphone - 此类对于键 authView 不符合键值编码

html - Mobile Safari 中的背景颜色和橡皮筋滚动

javascript - 类型错误 : 'undefined' is not a function even when using jQuery. 无冲突

javascript - 更新网址参数

JavaScript 选项卡仅在存在单个选项卡时才有效

iphone - Xcode Organizer 中的 "Use for Development"按钮对 iOS 设备有什么作用?

javascript - 如何根据背景更改全屏滚动上的导航文本颜色?

Javascript 或 Jquery : Scroll to Fixed position div