Loading

获取本机操作系统信息

//获取系统信息  terminal_type, terminal_edition,  put_system  参数的值
function agent() {
    var arr = [];
    var userAgentInfo = navigator.userAgent;
    var Agents = ["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;
        }
    }

    var start = userAgentInfo.indexOf('(');
    var end = userAgentInfo.indexOf(')');
    var str = userAgentInfo.slice(start +1,end);

    arr[0] = flag;
    arr[1] = str;
    return arr;
}

//result

//[true, "Windows NT 6.1; Win64; x64"]

posted @ 2018-05-24 09:37  算了个球  阅读(301)  评论(0编辑  收藏  举报