问题标签 [ios-standalone-mode]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
618 浏览

javascript - 在 Safari iOS 中检测独立模式

我的目标是向我们的网站添加一个 A2HS(添加到主屏幕)横幅,但如果用户正在 PWA 中,则不显示它。我看到网上很多人都在谈论,window.navigator.standalone但它根本不适合我。我已将其添加到我的if声明中:

这不起作用是有道理的,因为当我window.navigator.standalone在 Chrome 的控制台中输入时,它说这是undefined因为它根本不存在。也就是说,有没有人有解决方案来检测用户是否在移动 Safari 上处于独立模式?提前致谢!