In my web app, I need to know whether I can open a new window or not (e.g. with target='_blank'
). I can safely open a new window when running in a browser, but not when running as a PWA (in standalone
mode).
To test whether I can open a new window, I'm using the display-mode
media query, like this:
document.body.innerText = 'Your display-mode is ' +JSON.stringify(
['fullscreen', 'standalone', 'minimal-ui', 'browser'].filter(
mode => window.matchMedia(`(display-mode: ${mode})`).matches))
This works in Firefox and Safari, which both report the mode browser
. But Chrome, when its window is maximized, reports the mode fullscreen
! This doesn't make sense, because the meaning of fullscreen
is "All of the available display area is used and no user agent chrome is shown."
Questions:
browser
?