可以将“添加到主屏幕”的网址设为“在iPhone Safari上定制? [英] Can the url for the "Add to home screen" on iPhone Safari be customized?

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

问题描述

添加到主屏幕显示在网站的所有页面上,我希望该网址成为保存的主页。

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

我们非常感谢任何帮助。

Any help would be greatly appreciated.

推荐答案

我发现了一种解决方法。您可以通过 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.

还要注意用户选择的网址标记为应用可能是有意义的,但我会将其留给你自己的用户体验判断。

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.

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

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