在安卓系统上的"apple-mobile-web-app-title"

15
有没有类似于iOS 6中的meta标签apple-mobile-web-app-title的安卓网络应用程序等效物?是否有能够定义长标题和短标题的东西?
<title>Long name</title>
<meta name="apple-mobile-web-app-title" content="Short name">
4个回答

6

可以使用“application-name”元标签来实现。但是它似乎只能在Chrome中工作。Firefox和Android浏览器不使用标题标签。

<head> ...  <meta name="application-name" content="Awesome App!"> ...  </head>

来自“Web应用程序中的使用”部分
http://w3c-webmob.github.io/installable-webapps/


那么如何为Firefox设置默认标题呢? - Guru

2
创建一个名为site.webmanifest的JSON文件,内容如下:
{
  "name": "Long name",
  "short_name": "Short name",
  "icons": [
    {
      "src": "/android-chrome-192x192.png",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "/android-chrome-512x512.png",
      "sizes": "512x512",
      "type": "image/png"
    }
  ],
  "theme_color": "#ffffff",
  "background_color": "#ffffff",
  "display": "standalone"
}

然后像这样将其添加到您的HTML中:
    <link rel="manifest" href="/site.webmanifest">

"icons" 部分与你的问题无关,但你可能应该包括它们(并实际制作这些图标文件)。我从这篇文章中得到了这个建议:https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7


0

你可以使用JavaScript检测移动浏览器,然后将document.title更改为较短的标题来实现此目的:

if (navigator.userAgent.match(/(iPad|iPhone|iPod|Android|Silk)/gi))
   document.title = "Short Title";

0

Chrome自M39版本开始支持基于JSON的Web应用程序清单文件。字段short_name相当于Safari的apple-mobile-web-app-title,在有限的空间内显示完整名称时,例如应用启动器,它将被优先考虑。

short_name字段在Web应用程序清单文件中的W3C规范

short_name成员是一个字符串,表示Web应用程序名称的简短版本。它旨在用于无法显示Web应用程序完整名称的空间。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接