之前項目有需要在手機端判斷是蘋果/安卓,手機。進而使用不同的現在路徑。在網上找了找,現在把代碼放在這裡以備需要。
function(){
var isiOS = navigator.userAgent.match('iPad') || navigator.userAgent.match('iPhone') || navigator.userAgent.match(
'iPod'),
isAndroid = navigator.userAgent
.match('Android'),
isDesktop = !isiOS && !isAndroid;
if (isiOS) {
window.location = "https://appsto.re/cn/VMrvdb.i"
} else if (isAndroid) {
window.location = "http://www.tt-gate.com/download/tt_gate.apk"
} else {
alert("目前可能處于PC端 ,暫時不能下載下傳")
}
})