• js 判断window操作系统 2种方法



    js 判断window操作系统 1
    function
    detectOS() { 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"); if (isMac) return "Mac"; var isUnix = (navigator.platform == "X11") && !isWin && !isMac; if (isUnix) return "Unix"; var isLinux = (String(navigator.platform).indexOf("Linux") > -1); if (isLinux) return "Linux"; if (isWin) { var isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 || sUserAgent.indexOf("Windows 2000") > -1; if (isWin2K) return "Win2000"; var isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 || sUserAgent.indexOf("Windows XP") > -1; if (isWinXP) return "WinXP"; var isWin2003 = sUserAgent.indexOf("Windows NT 5.2") > -1 || sUserAgent.indexOf("Windows 2003") > -1; if (isWin2003) return "Win2003"; var isWinVista= sUserAgent.indexOf("Windows NT 6.0") > -1 || sUserAgent.indexOf("Windows Vista") > -1; if (isWinVista) return "WinVista"; var isWin7 = sUserAgent.indexOf("Windows NT 6.1") > -1 || sUserAgent.indexOf("Windows 7") > -1; if (isWin7) return "Win7"; } return "other"; } document.writeln("您的操作系统是:" + detectOS());
    js 判断window操作系统  2
     
    function mobile_device_detect(url){
                var thisOS=navigator.platform;
                var os=new Array("iPhone","iPod","iPad","android","Nokia","SymbianOS","Symbian","Windows Phone","Phone","Linux armv71","MAUI","UNTRUSTED/1.0","Windows CE","BlackBerry","IEMobile");
                for(var i=0;i<os.length;i++){
                    if(thisOS.match(os[i])){   
                        window.location=url;
                    }
                }
                if(navigator.platform.indexOf('iPad') != -1){
                    window.location=url;
                }
                var check = navigator.appVersion;
                if( check.match(/linux/i) ){
                    if(check.match(/mobile/i) || check.match(/X11/i)) {
                        window.location=url;
                    }  
                }
                Array.prototype.in_array = function(e){
                    for(i=0;i<this.length;i++){
                        if(this[i] == e)
                        return true;
                    }
                    return false;
                }
            } 
            var domain = document.domain;
            if(domain=='qcj.haodai05.cn'){
                mobile_device_detect("http://"+domain+"/mobile");
            }
            if(domain=='qcj.hxtz198.cn')
            {    
                mobile_device_detect("http://"+domain+"/mobile");
            }
            if(domain=='qcj.hxtz78.cn')
            {    
                mobile_device_detect("http://"+domain+"/mobile");
            }
            mobile_device_detect("http://www.qcj18.com/mobile");
    
    
    
    
    
  • 相关阅读:
    使用公钥和私钥实现LINUX下免密登录
    XML入门
    JSP页面中的errorPage属性和web.xml<error-page>标签的区别
    JAVA、TOMCAT环境变量配置
    在Eclipse Neon中导入serlvet-api等jar包
    56. Merge Intervals
    55. Jump Game
    34. Find First and Last Position of Element in Sorted Array
    33. Search in Rotated Sorted Array
    3. Longest Substring Without Repeating Characters
  • 原文地址:https://www.cnblogs.com/benpaodegegen/p/7338932.html
Copyright © 2020-2023  润新知