手机端判断安卓,iso,微信

var uaContains = function (key) {
    return navigator.userAgent.toLowerCase().indexOf(key.toLowerCase()) >= 0;
};
// can't just try "Android" as it might catch Windows Phone
var ANDROID = ['Linux', 'Android'].every(uaContains);
// can't just try "iPhone" as it might catch Windows Phone
var IOS = ['(iPhone;', '(iPod touch;', '(iPad;', '(iPod;'].some(uaContains);

var useragent = navigator.userAgent.toLowerCase();
var isWeixin = /micromessenger/i.test(useragent);
if (!IOS) {
    document.getElementById('android').style.display = 'block';
    document.getElementById('ios').style.display = 'none';
}

var androidBTN = document.getElementById('android');
androidBTN.addEventListener('click', function (e) {
    if (isWeixin && ANDROID) {
        document.getElementById('tipDiv').style.display = 'block';
        document.getElementById('tipimg').style.display = 'block';
        document.getElementById('tipDiv').style.height = document.documentElement.scrollHeight + 'px';
    }

});
posted @ 2018-12-08 16:45  大西瓜的一片净土  阅读(167)  评论(0编辑  收藏  举报