我使用以下代码:
if (navigator.platform == 'iPad' || navigator.platform == 'iPad Simulator' || navigator.platform == 'iPhone' || navigator.platform == 'iPhone Simulator' && window.navigator.standalone === false) {
window.alert("We've detected you're on iOS. Did you know that you can put us on your home screen? Tap the share icon, then tap 'Add to homescreen'.");
}
要提醒他们有一个独立选项可用,但它不起作用...奇怪的是我只在应用程序处于独立模式时才能获得它。我究竟做错了什么?
编辑:我实际上发现我在函数之外做代码。我认为这样会很好,但不是。