根据userAgent判断打开网页的所在终端,以及浏览器

function _IsIOS() {
    var ua = navigator.userAgent.toLowerCase();
    if(ua.match(/iPhone\sOS/i) == "iphone os") {
        return true;
    } else {
        return false;
    }
}

function _IsAndroid() {
    var ua = navigator.userAgent.toLowerCase();
    if(ua.match(/Android/i) == "android") {
        return true;
    } else {
        return false;
    }
}

function is_PC() {
    var userAgentInfo = navigator.userAgent;
    var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
    var flag = true;
    for(var v = 0; v < Agents.length; v++) {
        if(userAgentInfo.indexOf(Agents[v]) > 0) {
            flag = false;
            break;
        }
    }
    return flag;
}

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

function is_weibo() {
    var userAgent = window.navigator.userAgent.toLowerCase();
    if(userAgent.indexOf("weibo") > -1) {
        return true;
    } else {
        return false;
    }
}

function is_qq() {
var userAgent = window.navigator.userAgent.toLowerCase();
if(userAgent.indexOf("mqqbrowser") > -1) {
return true;
} else {
return false;
}
}

 

 

posted @ 2017-03-20 16:47  Sonya·Lv  阅读(471)  评论(0编辑  收藏  举报