js如何獲取微信版本號

1、判斷微信版本號html

 

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


其中 wechatInfo[1]  的值就是 版本號瀏覽器



2、js判斷是否在微信瀏覽器中打開微信

 

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



參考資料: js獲取微信版本號  http://www.studyofnet.com/news/905.htmlspa

相關文章
相關標籤/搜索