JS Judge Browser Terminal

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.