Determine whether the UserAgent is from WeChat and whether the UserAgent is from

Source: Internet
Author: User

Determine whether the UserAgent is from and whether the UserAgent is from

Iso:

Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/11B554a MicroMessenger/6.2.4 NetType/WIFI Language/zh_CN

 

Android:

Mozilla/5.0 (Linux; U; Android 4.4.2; zh-cn; PE-TL20 Build/HuaweiPE-TL20) AppleWebKit/533.1 (KHTML, like Gecko) version/4.0 MQQBrowser/5.4 TBS/025440 Mobile Safari/533.1 MicroMessenger/6.2.5.53 _ r2565f18.621 NetType/WIFI Language/zh_CN

 

After obtaining the UserAgent, you only need to determine whether the string contains "MicroMessenger"

C # judgment:

If (Request. UserAgent. ToLower (). Contains ("micromessenger") {// if it is a source}

Js judgment:

If (window. navigator. userAgent. toLowerCase (). indexOf ("micromessenger") {console. log ("OK ");}

At the same time, you can make other judgments, such as the operating system, and execute different codes according to different operating systems...

Related Article

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.