IdentificationSystem.js 5.4 KB
Newer Older
ksaria@outlook.com's avatar
ksaria@outlook.com committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
//判断系统
function AccessType() {
    try {

        var sUserAgent = navigator.userAgent;
        var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
        var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");
        var bIsIpad = sUserAgent.indexOf("iPad") > -1;
        var bIsIphoneOs = sUserAgent.indexOf("iPhone") > -1;
        var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
        var isLinux = (String(navigator.platform).indexOf("Linux") > -1);
        var bIsAndroid = sUserAgent.toLowerCase().match(/android/i) == "android";
        var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
        var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";

        if (isWin) {
            var isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 || sUserAgent.indexOf("Windows 2000") > -1;
            if (isWin2K)
                return 4;
            var isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 || sUserAgent.indexOf("Windows XP") > -1;
            if (isWinXP)
                return 3;
            var isWin2003 = sUserAgent.indexOf("Windows NT 5.2") > -1 || sUserAgent.indexOf("Windows 2003") > -1;
            if (isWin2003)
                return 5;
            var isWinVista = sUserAgent.indexOf("Windows NT 6.0") > -1 || sUserAgent.indexOf("Windows Vista") > -1;
            if (isWinVista)
                return 6;
            var isWin7 = sUserAgent.indexOf("Windows NT 6.1") > -1 || sUserAgent.indexOf("Windows 7") > -1;
            if (isWin7)
                return 1;
            var isWin8 = sUserAgent.indexOf("Windows NT 6.2") > -1 || sUserAgent.indexOf("Windows 8") > -1;
            if (isWin8)
                return 2;
            var isWin10 = sUserAgent.indexOf("Windows NT 10.0") > -1 || sUserAgent.indexOf("Windows 10") > -1;
            if (isWin10)
                return 14;
        }

        if (bIsAndroid)
            return 7;
        if (bIsIphoneOs)
            return 8;
        if (bIsIpad)
            return 9;
        if (bIsCE || bIsWM)
            return 10;
        if (isMac)
            return 11;
        if (isUnix)
            return 12;
        if (isLinux)
            return 13;
    }
    catch (e) {
    }
    return 0; //other
}

function explorerType() {
    try {
        var ua = navigator.userAgent.toLowerCase();
        var isStrict = document.compatMode == "CSS1Compat";
        if (ua.indexOf("opera") > -1)
            return 9;
        if (ua.indexOf("chrome") > -1)
            return 11;
        if (navigator.userAgent.indexOf("Firefox") > 0)
            return 10;
        if (ua.indexOf('webkit/5') != -1)
            return 12;
        if (ua.indexOf("msie 6") > -1)
            return 7;
        if (ua.indexOf("msie 7") > -1)
            return 1;
        if (ua.indexOf("msie 8") > -1)
            return 2;
        if (ua.indexOf("msie 9") > -1)
            return 3;
        if (ua.indexOf("msie 9") > -1)
            return 4;
        if (ua.indexOf("msie 11") > -1 || ua.indexOf("rv:11") > -1)
            return 5;
        if (ua.indexOf("msie 12") > -1 || ua.indexOf("rv:12") > -1)
            return 6;
        if (ua.indexOf("msie") > -1)
            return 13;
        if (ua.indexOf("gecko") > -1)
            return 14;
        if (ua.indexOf("rv:1.9") > -1)
            return 14;
    }
    catch (e) {
    }
    return 0;
}

var acsbrowser = {
    versions: function () {
        var u = navigator.userAgent, app = navigator.appVersion;
        return {//移动终端浏览器版本信息   
            trident: u.indexOf('Trident') > -1, //IE内核  
            presto: u.indexOf('Presto') > -1, //opera内核  
            webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核  
            gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核  
            mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端  
            ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端  
            android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器  
            iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器  
            iPad: u.indexOf('iPad') > -1, //是否iPad    
            webApp: u.indexOf('Safari') == -1, //是否web应该程序,没有头部与底部  
            weixin: u.indexOf('MicroMessenger') > -1, //是否微信   
            qq: u.match(/\sQQ/i) == " qq" //是否QQ  
        };
    } (),
    language: (navigator.browserLanguage || navigator.language).toLowerCase()
}
//部分落地专题页面自动跳转
$(document).ready(function () {
    //如果是手机端
    if (acsbrowser.versions.mobile || acsbrowser.versions.ios || acsbrowser.versions.android ||
        acsbrowser.versions.iPhone || acsbrowser.versions.iPad) {
        if (window.location.href.indexOf('www.acadsoc.com.cn/peixun/') > 0 || window.location.href.indexOf('www.acadsoc.com.cn/peixunban/') > 0) {
            window.location.href = window.location.href.replace('www.acadsoc.com.cn', 'm.acadsoc.com.cn')
        }
    }
    //如果是电脑端
    else {
        if (window.location.href.indexOf('m.acadsoc.com.cn/peixun/') > 0 || window.location.href.indexOf('m.acadsoc.com.cn/peixunban/') > 0) {
            window.location.href = window.location.href.replace('m.acadsoc.com.cn', 'www.acadsoc.com.cn')
        }
    }
});