The safari browser in the IOS system on the mobile phone can store the Webapp locally as an icon for users to view. So how do we let users enter the website from the home screen icon? We will introduce it slowly below.
The JavaScript code to determine whether to enter the website from the home screen icon is as follows##
//判断是否是从主屏幕图标进入的网站。(只针对IOS系统) if ('standalone' in navigator && !navigator.standalone && (/iphone|ipod|ipad/gi).test(navigator.platform) && (/Safari/i).test(navigator.appVersion)) { alert(1) } //通过判断navigator.standalone来确定是否是从主屏幕图标来进入网站的。 //这个主要是应用在webapp端还是web端进入网站的。从而进行相应的操作。 //本例是navigator.standalone等于false即是从浏览器(web端)进入的网站的。 //那么在document文档中写入两段代码。