“添加到主屏幕"的 url 可以吗?在 iPhone Safari 上可以自定义吗? [英] Can the url for the "Add to home screen" on iPhone Safari be customized?

查看:59
本文介绍了“添加到主屏幕"的 url 可以吗?在 iPhone Safari 上可以自定义吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

添加到主屏幕"显示在站点的所有页面上,我希望 URL 是被保存的主页.

The "add to home screen" shows up on all pages of a site, and I want the URL to be the homepage that gets saved.

例如在这个页面上:http://www.domain.com/category/page.html

添加到主屏幕"是否可以保存此网址:http://www.domain.com

Is it possible for the "Add to home screen" to save this url: http://www.domain.com

任何帮助将不胜感激.

推荐答案

我找到了一种解决方法.您可以通过 window.navigator 检测到您是从主页启动的.standalone 并基于潜在的重定向.

I found a sort-of workaround to this. You can detect that you were launched from the home page via window.navigator.standalone and based upon that potentially redirect.

另外,我做了一点测试,发现在最新的iOS上,不同的用户代理会报告给服务器,这开启了更快重定向的可能性.我找不到任何关于是否一直如此的信息.

Also, I have done a little testing and found that on the latest iOS, different user agents are reported to the server, which opens the possibility of a faster redirect. I can't find any information about whether this has always been the case.

从主页启动:

Mozilla/5.0 (iPhone; CPU iPhone OS 6_0_1 like Mac OS X) 
AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10A523

移动 Safari:

Mozilla/5.0 (iPhone; CPU iPhone OS 6_0_1 like Mac OS X) 
AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A523 Safari/8536.25

如果您的页面通过 AJAX 获取其大部分内容,或者您​​注意到服务器上的不同用户代理,则可能可以跳过重定向并就像"您在另一个 URL 上一样,因为在独立模式下无论如何,URL 是不可见的.我正在对此进行调查,但还不足以说明它是否会灼伤您.

If your page gets most of its content via AJAX or you notice the different user-agent on the server it might be possible to skip the redirect and just act "as if" you were at another URL, since in standalone mode the URL is invisible anyway. I'm investigating this but haven't got far enough to say whether it will burn you or not.

另请注意,用户选择将 URL 标记为应用可能很有意义,但我会将其留给您自己的用户体验判断.

Also note that the user's choice of URL to mark as an app may be meaningful, but I'll leave that to your own UX judgment.

这篇关于“添加到主屏幕"的 url 可以吗?在 iPhone Safari 上可以自定义吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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