如何从 Phonegap 应用程序的顶部停止屏幕滚动?
我目前正在使用Phonegap进行开发。它工作正常,除了顶部有一个小(约 1 像素)条,触摸它会导致整个应用程序滚动,这是我不想要的。这是我用来防止应用程序其余部分滚动的方法:
<div id="container" ontouchstart="stopIt(event, true);" ontouchmove="stopIt(event, true);" ontouchend="stopIt(event, false);">
stopIt = function(event, touching)
{
event.preventDefailt();
//Other code
}
CSS:
#container {
width:100%;
height:100%;
}
有谁知道可能导致此问题的原因,或者如何修复它?
I'm currently using Phonegap to develop. It works fine, except there's a small (~1 pixel) bar along the top, touching which will cause the entire application to scroll, which I don't want. Here's what I'm using to prevent the rest of the app from scrolling:
<div id="container" ontouchstart="stopIt(event, true);" ontouchmove="stopIt(event, true);" ontouchend="stopIt(event, false);">
stopIt = function(event, touching)
{
event.preventDefailt();
//Other code
}
And the CSS:
#container {
width:100%;
height:100%;
}
Does anyone know what could be causing this, or how to fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想你说的是 iPhone 顶部的状态栏?是的,它总是会滚动到顶部,并且无法从浏览器捕获此事件并阻止它。
您需要从本机端将 Web 视图的scrollToTop 属性设置为 false。那应该有效。
I think you're talking about the status bar on the top of an iPhone? Yes that will always scroll to the top, and there is no way to catch this event and stop it from the browser.
You'll need to set the web view's scrollToTop attribute as false from the native side. That should work.