According to this article, display-mode: standalone
only can detect on M48 or newer version. Is there any way to detect the mode on older version?
3 Answers
Answers 1
No this is not possible. Check this article
@supports for display-mode is only supported starting with Chrome 48.
Answers 2
Although it's not a direct answer but it's offering a workaround.
As much as I understand the article, you can configure your website (in the manifest.json) to open with querystring (for example) if it opens from the homescreen. So you can set a flag on the DOM - let's say add class to the body
tag. In this way you can detect in eitgher css or js if you run in standalone mode.
For example:
var isStandalone = false; if (location.search.indexOf('standalone=true') > -1) { isStandalone = true; document.body.classList.add('standalone-mode'); } // from now on you can check if you run in standalone by checking 'isStandalone' param.
header { background: red; } /* this is a style for standalone mode only */ body.standalone header { background: green }
Answers 3
For applications wrapped in electron you might use what is described here: https://github.com/electron/electron/issues/2288
window && window.process && window.process.type
or
navigator.userAgent.toLowerCase().indexOf(' electron/') > -1;
0 comments:
Post a Comment