How to obtain the micro-letter version number of JS _javascript tips

Source: Internet
Author: User

Micro-letters are now almost universally used, but the micro-mail version has been updated, different versions have different functions, so it is important to understand the micro-letter version number, so that they can update the experience of new features in a timely manner. So how to use JS to obtain the micro-letter version number?

First, to judge the micro-letter version number

var wechatinfo = Navigator.userAgent.match (/micromessenger\\/([\\d\\.] +)/i);
if (!wechatinfo) {
  alert ("This activity only supports micro-letters");
} else if (Wechatinfo[1] < "5.0") {
  alert ("This activity only supports micro-letter 5.0 versions"); 
  }

Where the value of wechatinfo[1] is the version number

Second, JS to determine whether in the micro-letter browser Open

function Is_weixn () {
  var ua = Navigator.userAgent.toLowerCase ();
  if (Ua.match (/micromessenger/i) = = "Micromessenger") {return
    true;
  } else {return
    false
  ;
}}

The above mentioned is the entire content of this article, I hope you can enjoy.

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.