gpt4 book ai didi

javascript - 在 iPhone Web 应用程序中禁用滚动?

转载 作者:IT王子 更新时间:2023-10-29 02:56:09 25 4
gpt4 key购买 nike

有什么方法可以完全禁用 iPhone 网络应用程序中的网页滚动吗?我已经尝试了很多在 google 上发布的东西,但似乎都不起作用。

这是我当前的页眉设置:

<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no;"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>

document.body.addEventListener('touchmove', function(e){ e.preventDefault(); });

好像不行。

最佳答案

更改为 touchstart 事件而不是 touchmove。在 One Finger Events 下它表示在平移过程中没有发送任何事件,因此 touchmove 可能为时已晚。

我将监听器添加到文档,而不是正文。

示例:

document.ontouchstart = function(e){ 
e.preventDefault();
}

关于javascript - 在 iPhone Web 应用程序中禁用滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2890361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com