PWAsForFirefox
PWAsForFirefox copied to clipboard
Changing the default links target option
Problem Description
In my PWA, I have code that opens external links and PDFs as new tabs or new windows with window.open(url, '_blank')
. This works in Chromium PWAs, and in in-browser Firefox, but it appears to be blocked in this standalone PWA mode. This is a problem, given that our CSP forbids opening external links or PDFs inside the iframe which contains the contents of our app, for security reasons. All such links must be opened in a new window or tab. But instead, in this version, the new document attempts to open as _top
.
Proposed Solution
Allow opening new windows or tabs from window.open(url, target)
and also (I did not test this) from anchors with target="_blank"
.
Additional Information
The current behaviour appears to treat the _blank
target as if it were the _top
target, which is problematic because any document opened with _blank
(or at least with window.open(url, '_blank')
) overwrites the PWA's HTML. It's sometimes possible to restore it with back arrow, but it often causes the PWA to reload, rather than returning the user to the last state of the PWA's UI.