zoukankan      html  css  js  c++  java
  • js 判断浏览器的类型和版本

    function browerTypeAndVersion(){
        var sys = {};
        var ua = navigator.userAgent.toLowerCase();
        var s;
        (s = ua.match(/msie ([d.]+)/)) ? sys.ie = s[1] : // ie11没有msie 可以用if("ActiveXObject" in window)来判断 true为ie false为非ie
        (s = ua.match(/firefox/([d.]+)/)) ? sys.firefox = s[1] :     // 另外可以用ua.match(/firefox[/s](d+)/)来判断是否为firefox
        (s = ua.match(/chrome/([d.]+)/)) ? sys.chrome = s[1] :
        (s = ua.match(/opera.([d.]+)/)) ? sys.opera = s[1] :
        (s = ua.match(/version/([d.]+).*safari/)) ? sys.safari = s[1] : 0;
        //以下进行测试
        if (sys.ie) document.write('IE: ' + sys.ie);
        if (sys.firefox) document.write('Firefox: ' + sys.firefox);
        if (sys.chrome) document.write('Chrome: ' + sys.chrome);
        if (sys.opera) document.write('Opera: ' + sys.opera);
        if (sys.safari) document.write('Safari: ' + sys.safari);
    }
  • 相关阅读:
    mysql使用group by查询报错SELECT list is not in GROUP BY clause and contains nonaggregated column...解决方案
    CentOS7 使用minikube 搭建kubernetes 学习环境
    5
    4
    3
    2
    1
    8
    7
    Algorithm
  • 原文地址:https://www.cnblogs.com/pumushan/p/4969178.html
Copyright © 2011-2022 走看看