设置“主屏幕”移动 Safari 的图标名称
默认情况下,当将网站“添加为书签”为图标时(通过从 Safari 的“+”菜单中选择添加到主屏幕),图标名称默认为页面的
与 apple-touch-icon 让您指定自己的页面图标化表示方式大致相同,网页是否可以指定除其 之外的默认图标名称。标题>
?
By default, when "bookmarking" a website as an icon (by choosing to Add to Home Screen from within Safari's "+" menu), the icon name defaults to the page's <title>
, truncated to 12 characters.
In much the same way that apple-touch-icon
lets you specify your own iconified representation of the page, is there a way for the webpage to specify a default icon name other than its <title>
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
对于 iOS:
对于 Android:
For iOS:
For Android:
为了在所有版本的 iOS 上获得更好的交叉兼容性,您可以使用答案组合(灵感来自 https://stackoverflow.com/a /13838563/1048705):
将此标签放入您的 iOS 6+ 文档中:
并使用此标签的内容作为不直接支持该标签的其他 iOS 版本的标题:
请注意,JavaScript 将更改以下标题:所有 iOS 客户端,包括 iOS 6+。
For better cross-compatibility on all versions of iOS, you could use a combination of answers (inspired by https://stackoverflow.com/a/13838563/1048705):
Place this into your document for iOS 6+:
and use this tag's content for the title for other iOS versions that don't support the tag directly:
Note that the JavaScript will change the title for all iOS clients, including iOS 6+.
似乎没有任何方法可以使用元标记或类似的东西来做到这一点。我的建议是使用服务器端逻辑为 iPhone 提供不同的标题。例如,在 php 中你可以这样做:
There doesn't seem to be any way to do this with meta tags or anything like that. My suggestion would be to use server-side logic to give iPhones a different title. For example, in php you could do something like this:
这就是我为我的虚构客户“Super Epic Resort Hotels”解决这个问题的方法,其缩写名称“SERH”可以满足 iOS 主屏幕图标名称限制。 (顺便说一句,该限制似乎基于字符数(我的 iPad 上为 13)和渲染宽度。)
用
字符填充名称,直到达到限制。就我而言,9 似乎就足够了,但您可以随时添加更多,以防万一。
将页面添加到主屏幕时,Safari 会建议名称:
实际上是
但用户不会注意到它们,因为
字符在 iOS 上不可见并且不占用空间,直到用户尝试退格名字。就我而言,用户必须退格 9 次才能退格“SERH”。
编辑:将此与上面的 qmega 解决方案结合使用,因为在非 iOS 设备上查看时,
字符可能会可见。
This is how I worked around it for my fictional client, "Super Epic Resort Hotels", which abbreviated name "SERH" can fit the iOS home screen icon name limit. (By the way, the limit seems to be based both on character count (13 on my iPad) and the rendered width.)
Pad the name with
characters until it reaches the limit. In my case, 9 seems to be sufficient but you can always add more just in case.
When adding the page to the home screen, Safari suggests the name:
which is actaully
but the user won't notice them, as the
characters are invisible on iOS and take up no space, until the user tries to backspace the name. In my case, the user has to backspace 9 times before he/she can backspace "SERH".
Edit: Use this in conjunction with qmega's solution above, as the
characters might be visible when viewed on non-iOS devices.
对于 iOS 6,请使用 Maarteen 的解决方案。为了与 iOS 5 兼容,您还可以使用 JS 更改标题:
可能最好使用 JQuery 将其附加到正文加载。
For iOS 6, use Maarteen's solution. For compatibility with iOS 5, you can also change the title using JS:
Probably best to attach this to body onload using JQuery.
您可以参考以下网址设置图标和名称:
https://developer.apple.com/library /ios/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
在头部添加以下代码:
You can refer below URL for setting icon and name :
https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
In head add below code :
我认为 safari 不会允许你将任何页面设为你的主页,最后将任何搜索引擎设为你的主页是没有用的
I think safari will not allow you to make any page your home page at the end there is no use of making any search engine your home page
在 iOS 6 中,这是通过元标记解决的:
正如 cwap 正确评论的那样:它现在是官方文档。以下是有关为 Web 应用设置
meta
标记的所有信息:https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.htmlIn iOS 6 this is solved with a meta tag:
As cwap rightly commented: It's now official documentation. Here's all the info on setting
meta
tags for web apps: https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html