确定网站是作为网络应用程序打开还是通过ipad上的常规Safari? [英] Determine if site is open as web app or through regular safari on ipad?

查看:118
本文介绍了确定网站是作为网络应用程序打开还是通过ipad上的常规Safari?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法确定访问者是在主屏幕上将我们的网站视为网络应用程序,还是经常通过ipad上的safari进行查看?

Is there a way to determine if a visitor is viewing our site as a web app on their home screen or regularly through safari on ipad?

推荐答案

我想通了:

确保有适当的网络应用元信息:

Make sure proper web app meta info is there:

<head>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" /> 

然后添加此脚本

<script>
if (window.navigator.standalone == true) {
 document.write('<p>Welcome Home</p>');
}else{
 document.write('<p>Tap the + button and choose "Add to Home Screen"</p>');
 document.write('<link rel="apple-touch-icon-precomposed" href="icon@2x.png"/>');
}
</script>
</head> 

所以, window.navigator.standalone 将如果他们在全屏web应用程序模式下查看,则为真。超级。

So, window.navigator.standalone will be true IF they are viewing in the fullscreen web app mode. Super.

来源:这是适用于iPhone,但它的工作方式相同,我知道如何做到这一点: http://www.bennadel.com/blog/ 1950-Detecting-iPhone-s-App-Mode-Full-Screen-Mode-For-Web-Applications.htm

Source: This is for iphone but it works the same and is where i figured out how to do it: http://www.bennadel.com/blog/1950-Detecting-iPhone-s-App-Mode-Full-Screen-Mode-For-Web-Applications.htm

这篇关于确定网站是作为网络应用程序打开还是通过ipad上的常规Safari?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆