1. 程式人生 > >獲取本機操作系統信息

獲取本機操作系統信息

ipad use dex urn OS oid start PE [1]

//獲取系統信息  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"]

獲取本機操作系統信息