如何在 iOS 的 Safari 中删除地址栏?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7890003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove Address Bar in Safari in iOS?
提问by firedev
Old trick with window.scrollTo(0,1); doesn't work. And even worse, the address bar moves only a bit and gets stuck halfway out sometimes.
window.scrollTo(0,1) 的老技巧;不起作用。更糟糕的是,地址栏只会移动一点,有时会卡到一半。
回答by Jon Dolan
It is a combination of many things as I have found when researching this issue for myself. Here's the code that properly works on iOS5: (I know I'm a little late, but an answer is an answer, hopefully it can help people in the future)
这是我在为自己研究这个问题时发现的许多事情的组合。这是在iOS5上正常工作的代码:(我知道我有点晚了,但答案就是答案,希望它可以在未来帮助人们)
<!DOCTYPE html>
<html>
<head>
<title>Hide Address Bar</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
window.addEventListener("load",function() {
setTimeout(function(){
window.scrollTo(0, 0);
}, 0);
});
</script>
<style>
body { min-height: 480px; }
</style>
</head>
<body>
<h1>Content</h1>
</body>
</html>
Source: http://24ways.org/2011/raising-the-bar-on-mobile
资料来源:http: //24ways.org/2011/rising-the-bar-on-mobile
Example: http://jsbin.com/isenax/
回答by Gotschi
i guess the code should still work..
我想代码应该仍然有效..
anyways here is the correct way to tell mobile safari that you want the full screen: click me
无论如何,这是告诉移动 safari 你想要全屏的正确方法: 点击我
e.g. use
例如使用
<meta name="apple-mobile-web-app-capable" content="yes" />
EDIT
编辑
Apple uses a new mobile-ui property to display a minimal UI in safari:
Apple 使用新的 mobile-ui 属性在 safari 中显示最小的 UI:
A property, minimal-ui, has been added for the viewport meta tag key that allows minimizing the top and bottom bars on the iPhone as the page loads. While on a page using minimal-ui, tapping the top bar brings the bars back. Tapping back in the content dismisses them again.
为视口元标记键添加了一个属性 minimum-ui,允许在页面加载时最小化 iPhone 上的顶部和底部栏。在使用最小用户界面的页面上,点击顶部栏会返回栏。再次点击内容会再次关闭它们。
use it like this:
像这样使用它:
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0, maximum-scale=1.0, minimal-ui" />
source: https://www.perpetual-beta.org/weblog/ios-7-dot-1-mobile-safari-minimal-ui.html
来源:https: //www.perpetual-beta.org/weblog/ios-7-dot-1-mobile-safari-minimal-ui.html
回答by svassr
Since IOS7 the window.scrollTotrick doesn't work anymore. There is no work around for the moment except to invite the user to add your website to Home Screen.
从 IOS7 开始,这个window.scrollTo技巧就不再起作用了。除了邀请用户将您的网站添加到主屏幕之外,目前没有其他解决方法。
http://www.mobilexweb.com/blog/safari-ios7-html5-problems-apis-review
http://www.mobilexweb.com/blog/safari-ios7-html5-problems-apis-review
Is it possible to hide the address bar in iOS 7 Safari?
Impossible to hide navigation bars in Safari iOS 7 for iPhone/iPod touch
回答by Clayton Gulick
On iOS 7 you can use the minimal-ui meta tag. Unfortunately, that was removed in iOS 8.
在 iOS 7 上,您可以使用 minimum-ui 元标记。不幸的是,这在 iOS 8 中被删除了。
For iOS 8 there's a project called brim that is supposed to bring back the minimal-ui type functionality. It can be found here: https://github.com/gajus/brim
对于 iOS 8,有一个名为 brim 的项目,旨在恢复最小用户界面类型的功能。可以在这里找到:https: //github.com/gajus/brim

