• 转载 js判断浏览器


    $scope.identifyBrowser= function () {
    var userAgent = navigator.userAgent,
    rMsie = /(msies|trident.*rv:)([w.]+)/,
    rFirefox = /(firefox)/([w.]+)/,
    rOpera = /(opera).+version/([w.]+)/,
    rChrome = /(chrome)/([w.]+)/,
    rSafari = /version/([w.]+).*(safari)/;
    var browser;
    var version;
    var ua = userAgent.toLowerCase();


    function uaMatch(ua) {
    var match = rMsie.exec(ua);
    if (match != null) {
    return { browser: "IE", version: match[2] || "0" };
    }
    var match = rFirefox.exec(ua);
    if (match != null) {
    return { browser: match[1] || "", version: match[2] || "0" };
    }
    var match = rOpera.exec(ua);
    if (match != null) {
    return { browser: match[1] || "", version: match[2] || "0" };
    }
    var match = rChrome.exec(ua);
    if (match != null) {
    return { browser: match[1] || "", version: match[2] || "0" };
    }
    var match = rSafari.exec(ua);
    if (match != null) {
    return { browser: match[2] || "", version: match[1] || "0" };
    }
    if (match != null) {
    return { browser: "", version: "0" };
    }
    }
    var browserMatch = uaMatch(userAgent.toLowerCase());
    if (browserMatch.browser) {
    browser = browserMatch.browser;
    version = browserMatch.version;
    }
    return {
    "browser": browser ,
    "version": version
    };
    }

    //判断当前页面时否在在IE浏览器下运行
    $scope.joinConf= function () {
    var temp = $scope.identifyBrowser();
    if (temp.browser == "IE") {
    if (!$scope.initActivxObj()) {
    }

    } else {
    alert("请选用IE浏览器!");
    }
    }

  • 相关阅读:
    rosbag 那些事
    rosbag record and play
    xsens melodic ros driver
    ros the public key is not available
    pyhton2与pyhton3切换
    期待已久的2013年度最佳 jQuery 插件揭晓
    MVC学习资料
    依赖注入框架Autofac的简单使用
    bootstrap
    https://nodejstools.codeplex.com
  • 原文地址:https://www.cnblogs.com/yhf286/p/3754869.html
Copyright © 2020-2023  润新知