简体   繁体   English

HTML 5固定屏幕iPad

[英]HTML 5 fixed screen iPad

I can't seem to find the right tag. 我似乎找不到正确的标签。 When the screen is swiped on iPad in certain places the whole screen moves, with the "rubber band" effect I know there is a way to lock the screen, specific to HTML5 and webkit. 当在某些地方在iPad上滑动屏幕时,整个屏幕都会移动,借助“橡皮筋”效果,我知道有一种锁定屏幕的方法,特定于HTML5和Webkit。

using <iframe src="" width="1024" height="724" scrolling="no"></iframe> 使用<iframe src="" width="1024" height="724" scrolling="no"></iframe>

seems like a cheap fix, these are my headers. 看起来像是便宜的修补程序,这些是我的标头。

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

Try this: 尝试这个:

<script>
    // document.body works probably too
    document.ontouchmove = function(e) {
        e.preventDefault();
    };
</script>

Note that this approach disables scrolling on the whole page! 请注意,此方法将禁用整个页面的滚动! Sometimes this might be undesirable. 有时这可能是不可取的。 If so, check out How to Disable Rubber Band in iOS Web Apps? 如果是这样,请查看如何在iOS Web Apps中禁用橡皮筋?

Just in case people don't read the comments on the answer, here is a solution I found when investigating to answers @bebraw 's comment: 以防万一人们不阅读答案的评论,这是我在调查@bebraw的评论时发现的解决方案:

How to disable rubber band in iOS web apps? 如何在iOS Web应用程序中禁用橡皮筋?

It is a lot of work for something so small but allows a granular approach on what get the scroll and what doesn't. 这么小的东西需要很多工作,但是可以采用细粒度的方法来了解滚动的内容和不滚动的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM