Home > Web Front-end > JS Tutorial > body text

js method to get WeChat version number_javascript skills

WBOY
Release: 2016-05-16 15:59:34
Original
1872 people have browsed it

微信现在几乎已经普遍在使用,但是微信版本一直在更新,不同的版本有不同的功能,于是了解微信的版本号很重要,以便自己及时更新体验新的功能。那么如何用js获取微信版本号呢?

一、判断微信版本号

var wechatInfo = navigator.userAgent.match(/MicroMessenger\\/([\\d\\.]+)/i) ;
if( !wechatInfo ) {
  alert("本活动仅支持微信") ;
} else if ( wechatInfo[1] < "5.0" ) {
  alert("本活动仅支持微信5.0以上版本") ;
}

Copy after login

其中 wechatInfo[1] 的值就是 版本号

二、js判断是否在微信浏览器中打开

function is_weixn(){
  var ua = navigator.userAgent.toLowerCase();
  if(ua.match(/MicroMessenger/i)=="micromessenger") {
    return true;
  } else {
    return false;
  }
}
Copy after login

以上所述就是本文的全部内容了,希望大家能够喜欢。

Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template