Safari Mobile / Force new window from standalone PWA
Asked Answered
T

0

6

There is a web app which runs in a standalone mode with the following manifest.json

{
 "lang": "de",
 "name": "Test.App",
 "short_name": "Test.App",
 "start_url": "/36485/",
 "display": "standalone",
 "theme_color": "#FF4500",
 "background_color": "#FFFFFF",
 "icons": [...]
}

There is no browser UI in this mode, so opening documents (like pdfs, docs, etc) must be done in a new Safari Window. Which brings me to the question: how do I force Safari to open a new browser window? The solution we have found now is to give it a different domain name(!!), ie. a subdomain. Every other option - be it window.open or taget=_blank - had no effect whatsoever and all the links would open in the same standalone window thus making it impossible to go back to the actuall app interface. External domain seems to do the trick. Is there any workaround to avoid using a subdomain? Maybe via some definitions in the manifest?

Tengdin answered 20/9, 2018 at 14:47 Comment(2)
I used a similar ugly hack but with a different protocol instead of domain. I point to the http version of the URL instead of the https one I use in the PWA. Obviously not an ideal solution as it might have security implications unless you're using HTST. link_element.onclick = function() { window.open(this.href.replace('https://', 'http://'), '_blank'); return false; } Coacher
Thanks, this comment should be an answer. I used this idea and had my server redirect http to httpsBedivere

© 2022 - 2024 — McMap. All rights reserved.