When doing mobile projects, you will often encounter the need to determine the page browsing terminal needs. To determine what browser terminal, first print navigator.useragent out. Therefore, several more commonly used methods are collected:
if (/(Iphone|ipad|ipod|ios)/i.test (navigator.useragent)) {//ios
Span style= "font-size:14pt" > Window.location.href = "https://itunes.apple.com/cn/app/fu-xing-zhi-hui-jia/ Id1081255502?mt=8 ";
}
else if (/(Android)/i.test ( navigator.useragent)) {//Android
Window.location.href = "Http://www.fxzhjapp.c om/wisdomhouse.apk ";
}
else {
alert (" Please download the client using your phone!) ");
}
function is_weixn () {//judgment
var ua = Navigator.userAgent.toLowerCase ();
if (Ua.match (/micromessenger/i) = = "Micromessenger") {
return true;
}
}
function Is_qq () {//QQ
if (Navigator.userAgent.toLowerCase (). IndexOf ("Mqqbrowser") >-1 && navigator.userAgent.toLowerCase (). IndexOf ("qq/") >-1) {
$ ('. Wximg '). CSS (' Display ', ' block ');
return true;
}
}
These are several common methods of judging the browsing terminal.
PS: How to determine whether the app is external or internal
If the page opens inside the app there will be a specific value, if not external. The general front end does not do this kind of operation, the PHP aspect directly judges. If you have to judge, let the app side provide the value is OK.
JS Judge Browser Terminal