简体   繁体   English

是否可以在普通网页上隐藏iOS浏览器chrome

[英]Is it possible hide iOS browser chrome on a normal webpage

So you can make a website go "full screen" and hide the addressbar/chrome on ipad if the user adds your page to their home screen, which makes an icon on the home screen that they launch your site from. 因此,如果用户将您的页面添加到主屏幕,您可以使网站“全屏”并隐藏ipad上的地址栏/ chrome,这会在主屏幕上显示他们启动您网站的图标。 You just put some meta tags like this: 你只需要放一些这样的元标记:

<meta name="apple-mobile-web-app-capable" content="yes" /> 
<meta name="apple-touch-fullscreen" content="yes" />

However, I haven't been able to get a site to hide the browser chrome when the page is just in a normal browsing session (the user hasn't launched your site directly from an icon on their home screen). 但是,当页面处于正常浏览会话中时,我无法让网站隐藏浏览器镶边(用户尚未直接从主屏幕上的图标启动您的网站)。 Is it possible to do so? 有可能这样做吗? How? 怎么样?

According to the Apple Docs it doesn't specifically say you can't (however as you've noted, it appears to only behave as desired when the site has been added to your home screen). 根据Apple Docs的说法,它没有具体说你不能(但是正如你所指出的那样,当网站被添加到你的主屏幕时,它似乎只是表现得很好)。

I also noted that on the Apple Support Forum the consensus seems to be that you need to launch from the home screen to get the desired effect. 我还注意到,在Apple支持论坛上,人们的共识似乎是您需要从主屏幕启动才能获得所需的效果。

Quote from Docs: 从文档引用:

apple-mobile-web-app-capable

Sets whether a web application runs in full-screen mode. 设置Web应用程序是否以全屏模式运行。

Syntax 句法

<meta name="apple-mobile-web-app-capable" content="yes">

Discussion 讨论

If content is set to yes, the web application runs in full-screen mode; 如果content设置为yes,则Web应用程序以全屏模式运行; otherwise, it does not. 否则,它没有。 The default behavior is to use Safari to display web content. 默认行为是使用Safari显示Web内容。

You can determine whether a webpage is displayed in full-screen mode using the window.navigator.standalone read-only Boolean JavaScript property. 您可以使用window.navigator.standalone只读布尔值JavaScript属性确定网页是否以全屏模式显示。

Availability 可用性

Available in iOS 2.1 and later. 适用于iOS 2.1及更高版本。

I found this works, 我发现这个有效,

$('body').delay('1000').animate({ scrollTop: '0px' }, 'slow');

I noticed that scrolling down removed it, so scrolled 60px (height of the chrome), but that hide it and scrolled down the page, but a scroll of 0px, assuming your page has started at the top (not on a # target), fools it! 我注意到向下滚动删除它,所以滚动60px(铬的高度),但是隐藏它并向下滚动页面,但滚动0px,假设你的页面已经从顶部开始(不是在#target上),傻瓜吧!

I guess you could even remove the delay and animate, but I wanted it to be smooth, and not too jerky. 我想你甚至可以删除延迟和动画,但我希望它是平滑的,而不是太生涩。

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

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