简体   繁体   English

即使向上拖动,如何隐藏移动浏览器的地址栏?

[英]How do I hide the address bar of mobile safari from appearing, even when dragged up?

I know there are many topics on this , but none of them do what Twitter/Google does. 我知道有很多话题,但是没有一个能像Twitter / Google一样。

Go to m.twitter.com on your iphone 4. When you drag, notice that the url bar never appears. 在iPhone 4上访问m.twitter.com。拖动时,请注意,URL栏永远不会出现。 UNLESS you drag Twitter's navigation bar on the top...then the url bar appears. 除非您将Twitter的导航栏拖动到顶部,否则将出现网址栏。

How can this be done? 如何才能做到这一点?

By scrolling the window just enough . 通过滚动窗口刚好 I've used the following in some production code. 我在一些生产代码中使用了以下内容。

if(/andro|iP[ha]/i.exec(navigator.userAgent) && !location.hash) scrollTo(0, 1);

EDIT: This won't prevent the URL bar from appearing at all, but it won't be visible upon page load. 编辑:这不会完全阻止URL栏出现,但在页面加载时将不可见。 The only way of totally not showing the address bar that I know of is to make the web page (a single web page, mind - URL navigation not allowed) "webapp enabled" via a meta tag, and have the user add it to their home screen. 完全不显示我所知道的地址栏的唯一方法是通过meta标签将网页(单个网页,记住-不允许URL导航)“启用webapp”,然后让用户将其添加到主屏幕。 That shortcut will then open a variant of Safari that has no chrome whatsoever. 然后,该快捷方式将打开没有chrome的Safari变体。

The trick Twitter uses is to design their site with the understanding of what part of the page most users are likely to grab. Twitter使用的技巧是在了解大多数用户可能会抓住页面的哪一部分的情况下设计其网站。 In most use-cases, you're going to scroll down your Twitter stream which leaves the button bar up top intact. 在大多数用例中,您将向下滚动Twitter流,使按钮栏保持原样。

Now try touching and dragging the button-bar down and you'll notice that the iPhone address bar actually appears at the top of the page. 现在,尝试触摸并向下拖动按钮栏,您会注意到iPhone地址栏实际上出现在页面顶部。 By scrolling the entire interface down upon page-load (like AKX described) and responding to the drag-events on the timeline separately from the full page, you get the perception that they've found a way to eliminate the address bar when it's not actually the case. 通过在页面加载时向下滚动整个界面(如所述的AKX)并与整个页面分开响应时间轴上的拖动事件,您会感觉到他们找到了一种消除地址栏的方法实际上是这样。

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

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