• 浏览器简易嗅探器


    document.write(navigator.userAgent);
    document.write('<br/>');
    document.write(navigator.platform);
    
    var client = function(){
    //引擎
        var engine = {
            ie:false,
            gecko:false,
            khtml:false,
            opera:false,
            webkit:false,
            ver:0
        };
    //浏览器
        var browser = {
            ie:false,
            firefox:false,
            chrome:false,
            safari:false,
            opera:false,
            ver:0,
            name:''
        };
    //系统
        var system = {
            win:false,
            mac:false,
            x11:false,
    
            sysname:''
        }
    
    
    //核心监测程序
        var ua = navigator.userAgent;
        var p = navigator.platform;
    
        if(p.indexOf('Win') == 0){
            system.win = true;
            system.sysname = 'Window';
        }else if(p.indexOf('Mac') == 0){
            system.mac = true;
            system.sysname = 'Macintosh';
        }else if(p == 'X11' || p.indexOf('Linux') == 0){
            system.x11 = true;
            system.sysname = 'Linux';
        }
    
        if(window.opera){
            engine.opera = true;
            engine.ver= browser.ver = window.opera.version();
            engine.name= 'Opera';
        }else if(/AppleWebKit/(S+)/.test(ua)){
            engine.webkit = true;
            engine.ver = RegExp['$1'];
            if(/Chrome/(S+)/.test(ua)){
                browser.chrome = true;
                browser.ver = RegExp['$1'];
                browser.name = 'Chrome';
            }else{
                borwser.safari = true;
                if(/Version/(S+)/.test(ua)){
                    browser.ver = RegExp['$1'];
                    browser.name = 'safari';
                }
            }
        }else if(/rv:([^)]+)) Gecko/d{8}/.test(ua)){
            engine.gecko = true;
            engine.ver = RegExp['$1'];
            if(/Firefox/(S+)/.test(ua)){
                browser.firefox = true;
                browser.ver = RegExp['$1'];
                browser.name = 'Firefox';
            }
        }else if(/MSIE ([^;]+)/.test(ua)){
            engine.ie = browser.ie = true;
            engine.ver = browser.ver = RegExp['$1'];
            browser.name = 'Internet Explorer';
        }
    
        return {
            engine:engine,
            browser:browser,
            system:system
        }
    
    }();
    
    
    
    alert(client.system.sysname + "目前使用的是" + client.browser.name + "浏览器,版本为" + client.browser.ver);
  • 相关阅读:
    kubernetes(十九) Ceph存储入门
    Kubernetes 使用 Weave Scope 监控集群(十七)
    在Mac下安装Wordpress
    关闭 Mac 上的虚拟内存
    Underlay、Overlay、大二层介绍
    Docker For Mac 下安装 Rancher
    Minikube-Kubernetes本地环境进行开发
    minikube---kubectl常用命令
    Mac安装minikube
    java内存模型
  • 原文地址:https://www.cnblogs.com/oceanden/p/3928053.html
Copyright © 2020-2023  润新知