当您从Chrome浏览器访问时,如何防止PWA应用程序打开target =“ _ blank”链接?

时间:2019-09-12 15:07:19

标签: javascript service-worker progressive-web-apps manifest.json mobile-chrome

当我尝试在Android移动设备上从Chrome 76/77打开它时,我的网站项目上的某些链接具有target =“ _ blank”,所有外部链接都由已安装(添加到主屏幕)的PWA应用程序打开。 我需要在新标签页中打开链接,而不是在PWA应用程序中打开链接。

我还尝试在清单文件中设置'scope':但这并不能解决我的问题。也许我可以更改另一个属性来防止这种行为。

{
  "name": "PWA reproducer",
  "short_name": "PWA reproducer",
  "description": "PWA reproducer",
  "orientation": "portrait",
  "background_color": "#d0112b",
  "theme_color": "#d0112b",
  "icons": [
    {
      "src": "https://reproducer-domain.com/images/logos/homescreen48.png",
      "sizes": "48x48",
      "type": "image/png"
    },
    {
      "src": "https://reproducer-domain.com/images/logos/homescreen72.png",
      "sizes": "72x72",
      "type": "image/png"
    },
    {
      "src": "https://reproducer-domain.com/images/logos/homescreen96.png",
      "sizes": "96x96",
      "type": "image/png"
    },
    {
      "src": "https://reproducer-domain.com/images/logos/homescreen144.png",
      "sizes": "144x144",
      "type": "image/png"
    },
    {
      "src": "https://reproducer-domain.com/images/logos/homescreen168.png",
      "sizes": "168x168",
      "type": "image/png"
    },
    {
      "src": "https://reproducer-domain.com/images/logos/homescreen192.png",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "https://reproducer-domain.com/images/logos/homescreen512.png",
      "sizes": "512x512",
      "type": "image/png"
    }
  ],
  "display": "standalone",
  "prefer_related_applications": false,
  "start_url": "https://reproducer-domain.com/?utm_source=homescreenPWA",
}

期望在新标签中打开target =“ _ blank”,而不是在移动设备上的Chrome中由PWA应用打开。

1 个答案:

答案 0 :(得分:0)

最终,这将包含在https://github.com/WICG/sw-launch/blob/master/explainer.md

中的提案中

我建议订阅该回购的更新以获取更多详细信息。

Chrome Status entry跟踪了Chrome的最终实现。

在撰写本文时,这并不是您可以控制的地方。