1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| const isAndroid=()=> { var browser = { versions: function () { var u = navigator.userAgent, app = navigator.appVersion; return { ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, iPhone: u.indexOf('iPhone') > -1, iPad: u.indexOf('iPad') > -1, }; }(), } if (browser.versions.android) return true; return false; }
if(isAndroid()){ alert('安卓环境') if(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)=="micromessenger") { alert('微信环境') }else{
}
}else{ alert('ios环境') }
|